For my application I would like to do the following:
SELECT *
FROM `LLS_USERS`
LIMIT 0,111
WHERE
(`USR_LOGIN`=
(CONCAT(
(SELECT LEFT(`USR_FIRST_NAME`, 1) FROM `LLS_USERS`;),
(SELECT `USR_LAST_NAME`FROM `LLS_USERS`;)
);
)
)
Basically I need to select all the rows in the user table where the user's login matches up with the first initial of the user name concatinated with the user's last name. So the SQL query will generate a table for me of all the selected rows where this is true in phpMyAdmin. I know I have 111 users in my database currently.
Does anyone know what's wrong with my syntax?
UPDATE: SOLUTION is:
SELECT *
FROM `LLS_USERS`
WHERE (
`USR_LOGIN` = ( left( `USR_FIRST_NAME` , 1 ) || `USR_LAST_NAME` )
)
LIMIT 0 , 111;
Take SQL as a (real life) Language here in this basic example:
Give me all rows of a table that match the condition loginname= 1 char of first name following lastname
->
Thats all, thats the beautiness of SQL