lxfdirs
asked on
Including items from various tables in a query MySQL.
Hi,
I need to generate a MySQL query based on a field from a table. My database contains 2 tables. On each record found by the query I need to include data from the other table. This other data should be linked based on a specific field on the record found by the main query.
Hope I have explained myself.
Regards
I need to generate a MySQL query based on a field from a table. My database contains 2 tables. On each record found by the query I need to include data from the other table. This other data should be linked based on a specific field on the record found by the main query.
Hope I have explained myself.
Regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Perhaps you could provide a bit more info and some sample data but I think you are trying to do this below ?
select * from tableA, tableB where tableA.ID = tableB.ID
select * from tableA, tableB where tableA.ID = tableB.ID
Don't use JOIN unless you absolutely have to, it's much messier and complicated to understand and debug.
Hi!
To speed up the query make sure that you have indexes on both tables
that matches the columns you use in the where clauses of the query . :)
Regards,
Tomas Helgi
To speed up the query make sure that you have indexes on both tables
that matches the columns you use in the where clauses of the query . :)
Regards,
Tomas Helgi
ASKER
Guys:
Thank you all for the suggestions.
I will be checking on them and come back to you with the accepted solution.
Regards
Thank you all for the suggestions.
I will be checking on them and come back to you with the accepted solution.
Regards
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
E.g.:
SELECT name FROM table1 WHERE id=(SELECT id FROM table2 WHERE field=3)