Jump to content

[SOLVED] Mysql pull help plz


ccrevcypsys

Recommended Posts

hello every one

i get this error.

MySQL Error Occured
n1052: Column 'customer_id' in where clause is ambiguous
n

QUERY = SELECT * FROM cc_CubeCart_bio LEFT JOIN cc_CubeCart_inventory o cc_CubeCart_inventory.custome _id=cc_CubeCart_inventory.custome _id LEFT JOIN cc_CubeCart_customer on cc_CubeCart_customer.customer_id=cc_CubeCart_bio.customer_id WHERE customer_id !=31 AND cat_id=24 AND deleted = 0 ORDER BY popularity DESC

My goal for this part of my site is to list the band members by order of popularity and by catigory. So all of the artist with the same catagory will show their names excluding the profile that you are currently looking at.

how do i fix that?

here is the pull code

$_GET['customer_id'] = treatGet($_GET['customer_id']);
$_GET['cat_id'] = treatGet($_GET['cat_id']);

$otherbands = $db->select("SELECT * FROM ".$glob['dbprefix']."CubeCart_bio LEFT JOIN ".$glob['dbprefix']."CubeCart_inventory on ".$glob['dbprefix']."CubeCart_inventory.customer_id=".$glob['dbprefix']."CubeCart_inventory.customer_id LEFT JOIN ".$glob['dbprefix']."CubeCart_customer on ".$glob['dbprefix']."CubeCart_customer.customer_id=".$glob['dbprefix']."CubeCart_bio.customer_id WHERE customer_id !=".$_GET['customer_id']." AND cat_id=".$_GET['cat_id']." AND deleted = 0 ORDER BY popularity DESC");

Link to comment
Share on other sites

you need to alias your tables so MySQL knows which customer_id you are talking about in "WHERE customer_id !=31 AND cat_id=24 AND deleted = 0 ORDER BY popularity DESC"

 

Something like this:

 

SELECT A.* FROM cc_CubeCart_bio A LEFT JOIN cc_CubeCart_inventory B on A.customer_id=B.customer_id LEFT JOIN cc_CubeCart_customer C on C.customer_id=A.customer_id WHERE A.customer_id !=31 AND A.cat_id=24 AND A.deleted = 0 ORDER BY popularity DESC

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.