Welcome to WebmasterWorld Guest from 54.145.55.135

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

MySQL Multiple Query

     
10:28 pm on Oct 14, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 7, 2006
posts:98
votes: 0


Hi,

I am trying to select data from two separate tables and display everything, not filter based upon information within both tables.

Example, i would like to join these to statements together:

SELECT first,last,email from users;

SELECT first,last,email from contacts;

Any ideas or direction? I have looked into JOINS but doesnt seem to be offering what i'm looking for.

Thanks!

10:47 pm on Oct 14, 2008 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5627
votes: 47


SELECT first,last,email from users
UNION
SELECT first,last,email from contacts;
11:20 pm on Oct 14, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Nov 22, 2005
posts:152
votes: 0


Both tables look very similal why are you storing same data twice?
12:41 am on Oct 15, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 7, 2006
posts:98
votes: 0


Different data, same fields....contacts contain information not relative to the users table...I will try the union...thanks!
12:44 am on Oct 15, 2008 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 7, 2006
posts:98
votes: 0


UNION was exactly what i was looking for. Thanks!
7:05 am on Oct 30, 2008 (gmt 0)

New User

5+ Year Member

joined:Dec 12, 2007
posts: 30
votes: 0


Which would be best for passing one login username/password to a main script and subscripts, for bypassing the need of the user to sign unto each and every sub script seperately...

Example would be for the main login to pass the active session to all of the multiple scripts in the entire site for automatic accessability without having to login for each new script.

Join, Union or a different process all together?