Is this possible in MySQL?
Let’s say i have a table:
ID, Name
Now, i want to run a query to see if these names exists “John,James,Bill”. Assuming only the name James exists in database (ID:23, Name:James) i wish to see this result:
ID | Name
------------
null | John
23 | James
null | Bill
Any ideas?
You need an outer join between your table and some table that contains the list of names for which you wish to search (you can either create such a table before running your query, or materialise such a table within the query using
UNIONas shown below). Learn about SQL joins.See it on sqlfiddle.