Hello, I'm using MySQL and I have two tables that look like this: table a +---+------+-----+ | ID | Name | ECT | +---+------+-----+ and table b +---+------+-----+ | ID | Name | ECT | +---+------+-----+ What I want to do is get all the names from table a where the id is 1 and all the names from table b where id is 1. But would it be faster to use two separate select query's or or one join query? Sorry if this is a stupid question just I'm not sure if joining tables is only for complex query's or if it's fast. Thanks for any help
Actually, making a join command would be faster bescause the program would not have to make a second round trip to the database with that separate select query. hope that helped
JOIN doesn't make sense in this example and you won't get what you need that way. Use UNION: SELECT name FROM a WHERE id = 1 UNION SELECT name FROM b WHERE id = 1 Code (markup):