houssam_ballout Posted May 22, 2013 Share Posted May 22, 2013 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 Quote Link to comment Share on other sites More sharing options...
DaveyK Posted May 22, 2013 Share Posted May 22, 2013 Set a static variable inside the query itself ( SELECT 'users' as 'table' FROM users ) UNION ALL ( SELECT 'messages' as 'table' FROM messages ) Quote Link to comment Share on other sites More sharing options...
Lala55 Posted May 27, 2013 Share Posted May 27, 2013 (edited) Query: <pre>SELECT * FROM sys.tables</pre> or <pre>SELECT * FROM sysobjects WHERE xtype = 'U'</pre> --- If you are using Oracle, you can use one of these: <pre>SELECT * FROM all_tables;</pre> or <pre>SELECT * FROM all_objects WHERE object_type = 'TABLE';</pre> Edited May 27, 2013 by Lala55 Quote Link to comment Share on other sites More sharing options...
Lala55 Posted August 5, 2013 Share Posted August 5, 2013 Query: <pre>SELECT * FROM sys.tables</pre> or <pre>SELECT * FROM sysobjects WHERE xtype = 'U'</pre> --- If you are using Oracle, you can use one of these: <pre>SELECT * FROM all_tables;</pre> or <pre>SELECT * FROM all_objects WHERE object_type = 'TABLE';</pre> Sometimes, the process of building and using queries is a simple matter of selecting fields from a table, perhaps applying some criteria, and then viewing the results. But what if, as is more often the case, the data you need is spread out in more than one table? Fortunately, you can build a query that combines information from multiple sources...... Duplichecker - free online plagiarism checker Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.