1 Replies - 402 Views - Last Post: 24 April 2012 - 07:47 AM Rate Topic: -----

#1 RayRayAngel  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 15-December 08

Getting Values from One Table then Getting Values Based On That

Posted 24 April 2012 - 07:42 AM

Hello Everyone!

It has sadly been a long time since I've been around these parts but today I've been presented with an interesting new issue.

Essentially I have been building out something for the past few weeks and today have found myself stumped.

I have some values in a MySQL table. For the sake of simplicity here I will call them $GTID. Each row has a unique TID assigned to it.

I have another table with what I call "links". In each of them is a value called $AID.

I want to run a query that subsequently runs another query. I'm not sure how this is done or if it is even possible.

$result = mysql_query("SELECT * FROM tasks_links WHERE `User` = '$UserWho'");
          while($row = mysql_fetch_array($result))
          {
          $GTID = $row['TID'];
          }


That allows me to spit out a list of TIDs but now I want to take that and take each $GTID and now get data from a different table that has a row named AID that matches the GTID variable.

Does anyone understand what I am trying to do and could help me figure this one out?

Is This A Good Question/Topic? 0
  • +

Replies To: Getting Values from One Table then Getting Values Based On That

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2951
  • View blog
  • Posts: 10,172
  • Joined: 08-August 08

Re: Getting Values from One Table then Getting Values Based On That

Posted 24 April 2012 - 07:47 AM

You want a join.
http://www.dreaminco...orum/159-mysql/
http://www.dreaminco...-on-inner-join/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1