The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> MySQL Help
|
How to get table name from SELECT?
Discuss How to get table name from SELECT? in the MySQL Help forum on Dev Shed. How to get table name from SELECT? MySQL Help forum discussing administration, SQL syntax, and other MySQL-related topics. MySQL is an open-source relational database management system (RDBMS).
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 27th, 2000, 08:02 PM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I have four tables (let's call them small tables), and in each are four identically named fields (ID, LName, FName, EMail). There is also other information that varies between tables.
I want to combine some of the data from each of the small tables into one big table to allow searches on all individuals. But I also want to create links in the search return where users can access the richer, more detailed information in the underlying small table.
Strategy to date:
<OL TYPE=A>
<LI>if big table exists, drop it
<LI>if big table not exist, create it
<LI>query small table, using INSERT INTO SELECT to populate big table
<LI>repeat query for each small table
</OL>
Problem: have not figured out how to add the source small table name into what is INSERTed into big table. Can get the unique id from small table, but getting table name and putting it into big table has me stumped URL.
Would appreciate some advice...
Tom
|

April 28th, 2000, 06:43 AM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 23
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Your database structure is not optimal.
You should create one table with all the products and common details. Let's say:
Prod_id, name, description, price. And for the specific details you make different tables (four different tables in you example). Let's say:
detailTable1: "Prod_id, 1detail1, 1detail2, 1detail3"
detailTable2: "Prod_id, 2detail1, 2detail3, 2detail3"
etc.
Mzzls
Dave
|

April 28th, 2000, 09:28 AM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 2
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Thanks, Dave. I agree, my table structure is not optimal. We started with one table, and as we incorporated very different groups of people, we let their differences as groups influence us, resulting in creating tables that are not normalized. Should have normalized then -- and this is on my long-range set of tasks -- but no time right now.
In the meantime, the workaround I would prefer would be a UNION of the tables, but that is not supported in my version of MySQL. Any other options or ideas will be much appreciated.
Tom
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|