Jump to content

Recommended Posts

mysql_query("select a.products_name, a.products_id, b.products_id, b.products_price from products_description a, products b where

a.products_id = b.products_id and b.products_price = '$price' and a.products_name = '$name'")or die("Error : " . mysql_error());

 

        anybody help me whats the problem in my query...?

Link to comment
https://forums.phpfreaks.com/topic/145181-problem-in-select-query/
Share on other sites

Try this:

SELECT a.products_name, a.products_id, b.products_id, b.products_price
  FROM products_description a
  INNER JOIN products b USING (products_id)
  WHERE b.products_price = '$price' AND a.products_name = '$name';

 

You may want to take a look at this tutorial as well: http://www.phpfreaks.com/tutorial/data-joins-unions

 

You might want to explain how it doesn't work though.

In addition, I always make it a practice to use quotes in my queries.

 

mysql_query("SELECT `a`.`products_name`, `a.`products_id`, `b`.`products_id`, `b`.`products_price` FROM `a`, `b` WHERE `a`.`products_id` = `b`.`products_id` && `b`.`products_price` = '" . $price . "' && `a`.`products_name` = '" . $name . "'")or die("Error : " . mysql_error());

 

Your tables appeared wrong according to your select string a.products_name = table name is 'a' and the field name is 'products_name'.  Replace the 'a' and 'b' table names with the table names you have.

 

As Daniel said, let us know the error message you are receiving...it helps us to help you solve your issue. :)

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.