Results 1 to 3 of 3

Thread: SQL Nightmare

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    andychev's Avatar
    andychev is offline Master Glow Jedi
    Join Date
    Apr 2005
    Location
    Chester, UK
    Posts
    150

    Unhappy SQL Nightmare

    Can anyone help with the following as its driving me insane ! Probably something really obvious but it has fried my brain now!

    I have two tables, Categories_stores, Categories_description.

    Ok put in english this is what i want to happen:

    I want to look into the stores table and select all the rows that are equal to a variable 'GLOBAL_CURRENT_STORE_NAME' obviously theae are all in the same column (categories_storename)

    This will give a big long list of numbers from this table under categories_id.

    I then want this column to be used to select all the corresponding records out of the categories description_table

    The sql i currently have is:

    $categories_query = tep_db_query("SELECT cd.categories_id, categories_name FROM " . TABLE_CATEGORIES_DESCRIPTION . " cd, " . TABLE_CATEGORIES_STORES . " cs WHERE language_id = $this_language_id and cd.categories_id = cs.categories_id and cs.categories_storename = '" . GLOBAL_CURRENT_STORE_NAME . "' ORDER BY categories_name");

    This just brings up the following error:

    1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'and cd.categories_id = cs.categories_id and cs.categories_store


    Am i missing something really obvious ! Any help would be much apreciated!
    Last edited by andychev; 05-22-2006 at 11:00 AM.

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14