Select Problem

Select Problem

am 06.12.2009 19:26:48 von Victor Subervi

--00163649a6f3e3b8d6047a137bdd
Content-Type: text/plain; charset=ISO-8859-1

Hi;
I have the following:

mysql> select * from categoriesProducts as c inner join relationshipProducts
as r on c.ID = r.Child inner join categoriesProducts as p on r.Parent = p.ID
where p.Category = prodCat2;
ERROR 1054 (42S22): Unknown column 'prodCat2' in 'where clause'
mysql> describe categoriesProducts;
+----------+-----------------+------+-----+---------+------- ---------+
| Field | Type | Null | Key | Default | Extra |
+----------+-----------------+------+-----+---------+------- ---------+
| ID | int(3) unsigned | NO | PRI | NULL | auto_increment |
| Category | varchar(40) | YES | | NULL | |
| Parent | varchar(40) | YES | | NULL | |
+----------+-----------------+------+-----+---------+------- ---------+
3 rows in set (0.00 sec)

mysql> select * from categoriesProducts;
+----+----------+--------+
| ID | Category | Parent |
+----+----------+--------+
| 1 | prodCat1 | None |
| 2 | prodCat2 | None |
+----+----------+--------+
2 rows in set (0.00 sec)

So I'm at a loss. No, 'prodCat2' isn't a column, but I don't understand how
I specified that in my query. Please advise.
TIA,
Victor

--00163649a6f3e3b8d6047a137bdd--

Re: Select Problem

am 06.12.2009 20:42:03 von edberg

At 1:26 PM -0500 12/6/09, Victor Subervi wrote:
>Hi;
>I have the following:
>
>mysql> select * from categoriesProducts as c inner join relationshipProducts
>as r on c.ID = r.Child inner join categoriesProducts as p on r.Parent = p.ID
>where p.Category = prodCat2;
>ERROR 1054 (42S22): Unknown column 'prodCat2' in 'where clause'
>mysql> describe categoriesProducts;
>+----------+-----------------+------+-----+---------+------ ----------+
>| Field | Type | Null | Key | Default | Extra |
>+----------+-----------------+------+-----+---------+------ ----------+
>| ID | int(3) unsigned | NO | PRI | NULL | auto_increment |
>| Category | varchar(40) | YES | | NULL | |
>| Parent | varchar(40) | YES | | NULL | |
>+----------+-----------------+------+-----+---------+------ ----------+
>3 rows in set (0.00 sec)
>
>mysql> select * from categoriesProducts;
>+----+----------+--------+
>| ID | Category | Parent |
>+----+----------+--------+
>| 1 | prodCat1 | None |
>| 2 | prodCat2 | None |
>+----+----------+--------+
>2 rows in set (0.00 sec)
>
>So I'm at a loss. No, 'prodCat2' isn't a column, but I don't understand how
>I specified that in my query. Please advise.
>TIA,
>Victor


You didn't quote prodCat2 in the query, so it was assuming you were
referring to the column name. Try:

select * from categoriesProducts as c inner join relationshipProducts
as r on c.ID = r.Child inner join categoriesProducts as p on r.Parent = p.ID
where p.Category = 'prodCat2';

- s

--
+----------------------------------------------------------- -------------+
| Steve Edberg edberg@edberg-online.com |
| Programming/Database/SysAdmin http://www.edberg-online.com/ |
+----------------------------------------------------------- -------------+

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: Select Problem

am 07.12.2009 10:26:18 von Victor Subervi

--0016364eeec0bfa46e047a200cad
Content-Type: text/plain; charset=ISO-8859-1

On Sun, Dec 6, 2009 at 2:42 PM, Steve Edberg wrote:

> At 1:26 PM -0500 12/6/09, Victor Subervi wrote:
>
>> Hi;
>> I have the following:
>>
>> mysql> select * from categoriesProducts as c inner join
>> relationshipProducts
>> as r on c.ID = r.Child inner join categoriesProducts as p on r.Parent =
>> p.ID
>> where p.Category = prodCat2;
>> ERROR 1054 (42S22): Unknown column 'prodCat2' in 'where clause'
>> mysql> describe categoriesProducts;
>> +----------+-----------------+------+-----+---------+------- ---------+
>> | Field | Type | Null | Key | Default | Extra |
>> +----------+-----------------+------+-----+---------+------- ---------+
>> | ID | int(3) unsigned | NO | PRI | NULL | auto_increment |
>> | Category | varchar(40) | YES | | NULL | |
>> | Parent | varchar(40) | YES | | NULL | |
>> +----------+-----------------+------+-----+---------+------- ---------+
>> 3 rows in set (0.00 sec)
>>
>> mysql> select * from categoriesProducts;
>> +----+----------+--------+
>> | ID | Category | Parent |
>> +----+----------+--------+
>> | 1 | prodCat1 | None |
>> | 2 | prodCat2 | None |
>> +----+----------+--------+
>> 2 rows in set (0.00 sec)
>>
>> So I'm at a loss. No, 'prodCat2' isn't a column, but I don't understand
>> how
>> I specified that in my query. Please advise.
>> TIA,
>> Victor
>>
>
>
> You didn't quote prodCat2 in the query, so it was assuming you were
> referring to the column name. Try:
>
>
> select * from categoriesProducts as c inner join relationshipProducts
> as r on c.ID = r.Child inner join categoriesProducts as p on r.Parent =
> p.ID
> where p.Category = 'prodCat2';
>

Thanks!
V

--0016364eeec0bfa46e047a200cad--