SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Query Problem...

    By running the following Query, I am getting this error message: Unknown table '00-0000' in where clause
    PHP Code:
    $results mysql_query('SELECT * FROM csa_partlist WHERE
       csa_partlist.partlist_id = `'
    .$tables[0].'`.partlist_id'
       or die(
    mysql_error()); 
    However, this query works fine.
    PHP Code:
    $resultsmysql_query('SELECT * FROM 
       `' 
    .$tables[0]. '` ') or die(mysql_error()); 
    Any thoughts. Thanks.

  2. #2
    Wadge! F4nat1c's Avatar
    Join Date
    Oct 2005
    Location
    South Wales, UK
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
     $query "SELECT * FROM csa_partlist WHERE
       csa_partlist = '"
    .$tables[0]."'";

     
    $result mysql_query($query)or die(mysql_error()); 
    Give that a try.
    OMFG SitePoint ROXORZ TEH BIG ONE111!
    Wish you were invisible?

  3. #3
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        $results mysql_query("SELECT * FROM csa_partlist WHERE partlist_id = '".$tables[0]."'")
       or die(
    mysql_error()); 
    -- Jelena --

  4. #4
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I belive there is misunderstanding about my query.
    I am trying to Join the Table (csa_partlist & $tables[0]) with the Partlist_ID column

    Here is the Query:
    PHP Code:
    $results mysql_query('SELECT * FROM csa_partlist WHERE
       csa_partlist.partlist_id = `'
    .$tables[0].'`.partlist_id'
       or die(
    mysql_error()); 
    Explanation:
    Select All From Table (csa_partlist)
    Where Table.Column (csa_partlist.partlist_id) = Table.Column ('.$tables[0].'.partlist_id)

  5. #5
    SitePoint Wizard silver trophy Jelena's Avatar
    Join Date
    Feb 2005
    Location
    Universum, 3rd Corner
    Posts
    3,000
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Ah, now I get it

    Try this out
    PHP Code:
     $results mysql_query("SELECT csa_partlist.*, ".$tables[0].".* FROM csa_partlist WHERE
       csa_partlist.partlist_id = "
    .$tables[0].".partlist_id")
       or die(
    mysql_error()); 
    -- Jelena --

  6. #6
    SitePoint Addict
    Join Date
    Jul 2005
    Posts
    215
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jelena & F4nat1c

    I found the Problem. In my Query, I only included one table (FROM csa_partlist) instead of two tables as shown below.
    PHP Code:
    $results mysql_query('SELECT * FROM csa_partlist, `'.$tables[0].'` WHERE 
       csa_partlist.partlist_id = `'
    .$tables[0].'`.partlist_id'
       or die(
    mysql_error()); 


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
  •