Connecting Tech Pros Worldwide Help | Site Map

select from 2 tables and

  #1  
Old March 9th, 2009, 05:28 PM
Newbie
 
Join Date: Mar 2009
Posts: 1
Hello, im new to mysql and i could find anything on the internet to help me so ill post my q here.

First im running mysql 5.0.67. I have to tables

allusers:
-id_user
-help
-team_user
-own_emal

players:
-id_player
-name_player
-owner_name
-owner_id
-owner_team_id

So this is my 2 tables. What im trying to do is reading from this tables to look if id_user is the same number with owner_team_id , and if it is the same show only stats that is from specific user

Thank you
Michael
  #2  
Old March 10th, 2009, 02:31 PM
mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 711
Provided Answers: 1

re: select from 2 tables and


I didn't understand you completely. Are you looking for this?
Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM allusers users 
  2. INNER JOIN players p ON p.owner_team_id = users.id_user
  3. WHERE users.id_user = 'some user id here'
  #3  
Old June 30th, 2009, 09:23 AM
Member
 
Join Date: Dec 2007
Posts: 47

re: select from 2 tables and


If you give those two columns the same name you could use something like this..

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM users  
  2. LEFT JOIN players USING (id_user)
  3. WHERE id_user = 'user id' 
  4.  
Reply


Similar Threads
Thread Thread Starter Forum Replies Last Post
TSQL - IF EXISTS SELECT From Mulitple Tables Jonathan Woods answers 1 October 21st, 2008 11:45 AM
Is a statement like this possible: SELECT * FROM (CALL myProcedure) Markus answers 5 November 12th, 2005 11:55 AM
Unable to select from temporary tables Andy S. answers 2 November 12th, 2005 11:33 AM
List of columns from tables across databases. OhMyGaw answers 6 July 23rd, 2005 10:25 AM
SQL Statement select from one table where not in another table Michael answers 6 July 20th, 2005 03:00 AM