Ronan Lucio wrote:

Hi,

Supposing we have for tables:
One master table (student) and three independent tables.
There is no relationship between them.
Each of the three table have a relationship with table student.

City      | Teacher   | TestLocal
====      | =======   | =========
city_id   | teac_id   | test_id
city_name | teac_name | test_name

Student
=======
stud_id
stud_name
city_id
teac_id
test_id

When the application shows the student screen, itīs need
to make 4 SQL queries.

Is it wise to make only one query even donīt having any
relations ship between the three ones?

SELECT city_name, teac_name, test_name
FROM City, Teacher, TestLocal
WHERE city_id = Student.city_id
AND teac_id = Student.teac_id
AND test_id = Student.test_id
AND Student.stud_id = $cod_student


SELECT city_name, teac_name, test_name
FROM Student
LEFT JOIN City ON Student.city_id=City.city_id
LEFT JOIN Teacher ON Student.teac_id=Teacher.teac_id
LEFT JOIN TestLocal ON Student.test_id=TestLocal.test_id
WHERE Student.stud_id = $cod_student


Or is it better to make 3 distinct SELECT?

What should be better for the application and DB?

Thanks,
Ronan






-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to