Off the top of my head, I'm sure you'd do it like this:
SELECT
products.id,
COUNT(orders.id) AS hits
FROM
products,
orders
WHERE
orders.product_id = products.id
AND hits >= products.quantity
GROUP BY products.id
Tried that:
ERROR 1054: Unknown column 'hits' in 'where clause'
Michael Stassen wrote:
No, you can't use an alias in the WHERE clause. Even if you could,
you'd have a problem here. The WHERE clause is used to decide which
rows to look at in advance of any calculations. You're asking mysql
to count the rows which match the WHERE clause, but you're also as
Use unsigned tinyint(1) with 1 and 0 as values.
On 13/07/2003 19:41, Dan Anderson wrote:
I ran a search through the mySQL manual and google and could not find a
satisfactory answer. Does mySQL support the declaration of a boolean
data type? Currently I am using VARCHAR(6)s with either 'TRUE' or
Hello,
I would like to know the status of the UTF8 support in MySQL 4.1.
I tried to create a table using utf8 charset, and inserting hebrew text
into it. it seems like it still treats this text as binary - for example
the length() function returns 8 on 4 chars string, or when cretting a
column
he database
once
> (for optimum performance).
>
> - Carsten
>
> > -Oprindelig meddelelse-
> > Fra: Sagi Bashari [mailto:[EMAIL PROTECTED]]
> > Sendt: 27. maj 2002 20:50
> > Til: olinux; [EMAIL PROTECTED]; [EMAIL PROTECTED]
> > Emne: Re: building tree
Yeah, thats exactly what I wanted to do. But how do I make MySQL sort it
like that? Show the parent first, and then all its childs, so the
application can determite if it's subcategory by checking if the parent is
was changed.
Sagi
From: "olinux" <[EMAIL PROTECTED]>
> create a table like this
Hi,
I'm trying to build a simple categories tree in MySQL.
Say I have the following table:
CREATE TABLE test (
id int(10) unsigned NOT NULL auto_increment,
parent int(10) unsigned NOT NULL default '0',
name tinytext NOT NULL,
PRIMARY KEY (id),
KEY parent (parent)
) TYPE=MyISAM;
+---