Jump to content
Sign in to follow this  
houssam_ballout

get the table name from query that query 3 tables

Recommended Posts

Hello,I had this issue in mysql:I had made a query which select data from 3 tables, using UNION command, and its getting the results, when I want to display the results in a php page , I need to know the table that each record had been retrieved from, how can I do it?Thanks in advance

Share this post


Link to post
Share on other sites

Include the table name as a field. SELECT 'table1' AS `table`, * FROM table1 UNION SELECT 'table2' AS `table`, * FROM table2 UNION SELECT 'table3' AS `table`, * FROM table 3

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...