SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2001
    Posts
    140
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to retrieve data from another table?

    Hi, I have a mySQL query that looks like this...

    $pricedropresult = mysql_query("SELECT hardware.productname, productid, date1, date2, date3, date4, price1, price2, price3, price4, drop1, drop2, drop3, drop4 FROM hardware, deals where drop1 < drop2 OR (drop1+drop2) < 0");

    Apparently, it didn't work. I cannot put id=$id following the WHERE part. So, I was wondering if it's still possible to retrieve the 'productname' from the other table. 'productid' corresponds to the 'id' in 'hardware' table.

    This query is intended to yield multiple results.

    Thanks!

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any error message?
    Ambiguous field name somewhere?

    Example; how to get all rows from tables a and b with the same ids and where id for table a is 1..3

    select a.id, a.name, b.id, b.name
    from a, b
    where a.id = b.id and a.id between 1 and 3;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •