column_name1,
column_name2...
FROM
tables
[WHERE conditions]
[GROUP BY group
[HAVING group_conditions]
]
[ORDER BY sort_columns]
[LIMIT limits];
Example:
SELECT
tbl_users.id,
tbl_users.username,
tbl_users.`password`,
tbl_users.firstname,
tbl_users.lastname
FROM
tbl_users;
WHERE Clause - select a particular rows which match its conditions
SELECTtbl_users.id,
tbl_users.username,
tbl_users.`password`,
tbl_users.firstname,
tbl_users.lastname
FROM
tbl_users
WHERE
tbl_users.id = '1';
GROUP BY- allows use to retrieve rows in group
SELECTtbl_users.id,
tbl_users.username,
tbl_users.`password`,
tbl_users.firstname,
tbl_users.lastname
FROM
tbl_users
GROUP BY
tbl_users.lastname
ORDER BY - sort the result set on one or more column in ascending or descending order
SELECTtbl_users.id,
tbl_users.username,
tbl_users.`password`,
tbl_users.firstname,
tbl_users.lastname
FROM
tbl_users
ORDER BY
tbl_users.lastname
1 comments:
Interesting variant
Post a Comment