Working with MySQL (Cheap hosting) SQL 44 | blewis |
Working with MySQL SQL 44 | blewis | 20021014112252 | +———–+—————-+ 8 rows in set (0.00 sec) This query returns the username and timestamp for all rows in the table in descending order, thus displaying the accounts most recently entered. Changing Column Names If you look back at the previous query, you can see that the output table heading displays the string values for the columns in the table as entered when the table was first created. When we obtain the results of a query both in the client tool and programmatically, the same column names are used. We have the option of changing the displayed values. For example: mysql> SELECT acc_id ‘Account ID’, username ‘Username’, ts ‘Timestamp’ FROM acc WHERE ts < now() ORDER BY ts desc; +------------+-----------+----------------+ | Account ID | Username | Timestamp | +------------+-----------+----------------+ | 1034546 | jjmyers | 20021014113422 | | 1034154 | ysheets | 20021014113416 | | 1034089 | sstanford | 20021014113407 | | 1034067 | jthompson | 20021014113403 | | 1034055 | jdoe | 20021014112501 | | 1034033 | jsmith | 20021014112438 | | 1034034 | jime | 20021014112415 | | 1034123 | blewis | 20021014112252 | +------------+-----------+----------------+ 8 rows in set (0.00 sec) In this sample query, the three columns pulled from the table aren t displayed with their table names of acc_id, username, and ts, but new names are listed in the query. Although the column name change doesn t have anything to do with the data itself, it does provide a better presentation to the user. Like Another common problem with queries against a database is trying to find the exact row you are interested in using. For example, suppose you know that there is an account in the database table acc with a username ending with smith, but you don t know exactly what the full string is. If you attempt to query just using smith, you might find rows with usernames of smith but nothing else.
Note: If you are looking for good and quality webspace to host and run your java application check professional java hosting services