I'm new to JOINS in MySql.
I have six tables: t1, t2, t3, t4, t5, t6.
And I also have one main table: main_table
.
TOTAL 7 TABLES!
The first column of ALL tables is called classified_id
.
If the user searches for "cars" then the main table will match everything in table t1 (which is the cars table) where classified_id is the same in both tables.
So:
SELECT * FROM main_table, t1 WHERE main_table.classified_id=t1.classified_id
This works fine, although I am not sure this is the way to join here. Performance is an issue in my case!
However, here is my problem.
Whenever ALL CLASSIFIEDS are searched, then I need to match the main_table.classified_id
to the other tables classified_id
column and get every classified there is.
How should this query be made up?
SELECT * FROM main_table, t1, t2, t3, t4, t5, t6 // I have this so far which is not much!
If you need more input just ask and I will update this Q.
Thanks
EDIT: Table setup:
main_table: t1:
ID(PK) ID (PK)
classified_id -> 25 classified_id -> 25
category -> CARS year -> 1997