Ask a Question related to Coldfusion Database Access, Design and Development.
-
cf101 #1
MySQL Query Problem
:confused;
What is wrong with the following Query? It's in the book, but not working.
Select OrderID, OrderDate,
(SELECT Count (*)
From MerchandiseOrdersItems oi
Where oi.OrderID = o.OrderID) AS ItemCount
FROM MerchandiseOrders o
Where ContactID = #Session.Auth.ContactID#
ORDER By OrderDate DESC
cf101 Guest
-
mysql++ i mysqlpp::Query problem
Hello all! I've a problem with mysql++-2.1.1 examples. Compiler compiles properly but when I create Query object program crashes (when it is... -
mySQL query writing problem
I have a table with a dozen or so fields. I am trying to return all 12 fields in all records that contain an entry in the field named 'week'. This... -
Query problem moving from mysql 4 to 5
I am currently developing a website that is used to display college course information. I have everything running exactly as intended on my server... -
PHP/MySQL Query Problem in Dreamweaver
I am trying to retrieve data from mysql database using php code in Dreamweaver. It is a simple query that is supposed to list all entries from... -
Problem with MySQL Query
Problem with mySQL Query This is the query I have: $dbqueryshipping1 = "select * from tempuserpurchase where... -
The ScareCrow #2
Re: MySQL Query Problem
but not working
Does it give an error, return nothing, what ?
What book ?
Can you use sub selects with mySQL ?
Ken
The ScareCrow Guest
-
cf101 #3
Re: MySQL Query Problem
The book is ColdFusion MX by Ben Forta Nate Weiss
Error Message is:
Syntax error or access violation: You have an error in your SQL syntax near
'SELECT Count (oi.OrderID) From MerchandiseOrdersItems oi Where oi.OrderID ' at
line 2
Originally posted by: The ScareCrow
but not working
Does it give an error, return nothing, what ?
What book ?
Can you use sub selects with mySQL ?
Ken
cf101 Guest
-
paross1 #4
Re: MySQL Query Problem
If you are using an "older" version of MySql (before 4.1.x), then you can not perform subselects in your queries.
Phil
paross1 Guest
-
d_adams #5
Re: MySQL Query Problem
I'm new at this too, but is there a problem using the alias "o.OrderID" before
it is declared in the next line? What if you used the regular table name
"MerchandiseOrders.OrderID" instead?
I may be completely off base, but it just sets off an alrm to me when you use
something before it is declared. :confused;
d_adams Guest
-
The ScareCrow #6
Re: MySQL Query Problem
The problem with the query is this code
(SELECT Count (*)
From MerchandiseOrdersItems oi
Where oi.OrderID = o.OrderID) AS ItemCount
As I suspect that the version of mySQL being used does not allow sub selects
Ken
The ScareCrow Guest
-
mxstu #7
Re: MySQL Query Problem
Assuming you're using a version of mySQL that supports subqueries (mySQL 4.1.?
or higher)...
Just remove the space between Count and (*).
--- Tested with mySQL 4.1.9
SELECT OrderID, OrderDate,
(SELECT Count(*)
FROM MerchandiseOrdersItems oi
WHERE oi.OrderID = o.OrderID) AS ItemCount
FROM MerchandiseOrders o
WHERE ContactID = #Session.Auth.ContactID#
ORDER By OrderDate DESC
mxstu Guest
-
cf101 #8
Re: MySQL Query Problem
Hi guys!
It looks like old versions of MySQL do not support Sub Select quiries.
cf101 Guest



Reply With Quote

