2 Replies - 1360 Views - Last Post: 22 April 2009 - 12:59 AM Rate Topic: -----

#1 dangmnx  Icon User is offline

  • D.I.C Regular

Reputation: -1
  • View blog
  • Posts: 428
  • Joined: 10-April 09

how can i add two query()

Posted 21 April 2009 - 08:16 PM

i have two tables under my account called test one is called members, the other is called matches 2

here is the code for matches2

$result = mysql_query("SELECT id, date, code2, winner, pointsg, loser, pointsl, replay FROM matches2 ORDER BY id DESC");


i would like to add a table from members in matches 2, is that possible?

here the code for members
$result = mysql_query("SELECT code, setname, rating1, wins, loses FROM members ORDER BY rating1 DESC LIMIT 5 ");


i want to add the id "rating1" inside matches2. how can i write that?

This post has been edited by dangmnx: 21 April 2009 - 08:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: how can i add two query()

#2 maffelu  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 41
  • View blog
  • Posts: 190
  • Joined: 21-August 08

Re: how can i add two query()

Posted 21 April 2009 - 11:04 PM

You want to look at foreign keys I think:

morkalork.com/SubArticles/gener...n-key-works.htm
java2s.com/Tutorial/MySQL/0080_...ForeignKeys.htm

This post has been edited by maffelu: 21 April 2009 - 11:05 PM

Was This Post Helpful? 1
  • +
  • -

#3 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: how can i add two query()

Posted 22 April 2009 - 12:59 AM

I covered this in a post yesterday if you want to take a look:

http://www.dreaminco...topic100676.htm

You need to use JOINs to connect multiple database tables

This post has been edited by pemcconnell: 22 April 2009 - 12:59 AM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1