I have a db with 8 tables which intend to search for an id number by joining them but i would like to retrieve the name of the table to use in a php along the lines of…
if($tablename == 'accounts'){
echo 'value found in accounts';
}
What would the mysql query be?
(I don’t need help with the joining etc, just the bit that would get the table name and how to store it in $tablename)
Thanks
How can you search for data in a table if you don’t know the table name in the first place?
So I suppose that you already know the table names, and don’t need things like
SHOW TABLES; that you have e.g. aWHEREof the formand once retrieved a row, you know it matches, but you don’t know where the match did occur. And running eight straight queries instead of one JOINed isn’t an option.
If this is the case, you’ll have to supplement your SELECTed fields with a flag to tell you what you need:
Then in PHP when retrieving the row, you will just use the field: