Page 1 of 1

Searching in 2 tables.

Posted: Sat Jul 17, 2004 7:16 am
by /usr/local/
Hi,

I have 2 tables which are they students and users.

I have a form. That I am recording form details in students table.

student table includes
id - name - surname - email

When I approve students request, I copies from students table to users table.

users table includes same fields as students.

I can add add a field to students or users like status and giving them 0 or 1 data to checking it's approved or not. But I have a search page too, so I want to search it quickly, It would be lots of datas on students table.

Am I on right way?

My question is how can I make search on 2 tables in same time?

Thank you.

Re: Searching in 2 tables.

Posted: Sat Jul 17, 2004 7:52 am
by zenabi
If both tables have the same fields then it will be wise to have just one table and do as you said:
I can add add a field to students or users like status and giving them 0 or 1 data to checking it's approved or not.
I don't understand this though:
But I have a search page too, so I want to search it quickly, It would be lots of datas on students table

Posted: Sat Jul 17, 2004 8:34 am
by kettle_drum
Search two tables at once:

Code: Select all

SELECT table.id, table.name, table2.id, table2.name FROM table, table2 WHERE table.id = '5' AND tablo.id = table2.id
But you would be best to use one table to store all the info as you suggest. Dont worry about having lots of entries in the table...it will still be fairly fast.