Currenty I have records like below :
-
name|score|
tony|23|
john|32|
eddy|25|
mark|21|
nick|26|
alex|27|
nick|23|
I want to request table with only name like : tony, john, eddy, mike, paul
using this query below ;
SELECT name,
name
FROM a_team
WHERE (name LIKE 'tony%' or name LIKE 'john%' or name LIKE 'eddy%' or name LIKE 'mike%' or name LIKE 'paul%')
the result is :
-
name|score|
tony|23|
john|32|
eddy|25|
Since name like: mike and paul have no record yet
how do I request table with above query with result displaying
mike and paul = "n/a" in field "score" as below ?
-
name|score|
tony|23|
john|32|
eddy|25|
mike|n/a|
paul|n/a|
Thanks for response
2
Answers
You cannot transfer the names from the criteria to the output rowset. You must make your criteria a rowset and join existing data to it:
1- You can set the default values for the column, so when there is no value in the field it will return the default value from the database, for example for scores if your table name is
scores
you can run the query;NOTE: N/A cannot be set for an integer field so you have to use varchar()
2- You can use
IFNULL
to replace the null values from the column: