Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CREATE TABLE PROBLEM 1

Status
Not open for further replies.

juuso79

Programmer
Nov 15, 2001
22
FI
Hi what is wrong in this line.

mysql_query("CREATE TABLE shipments2 TYPE=HEAP SELECT ID_number, count(On_time) FROM Shipments WHERE On_time = 1 GROUP BY ID_number");

Im trying to count how many On_time rows is there with the number 1 in it. According to ID_number. Im using PHP/MySQL/Apache.

I have for example this kind of Shipments -table:

ID_number On_time
12345 1
12345 1
12345 0
12345 1
22222 0
22222 1
22222 1

And I want new table to be like this:

ID_number On_time
12345 3
22222 2


Thanks in advance!!!
 
try this:

CREATE TABLE shipments2 (ID_number INT, CountColumn INT) TYPE=HEAP SELECT ID_number, count(On_time) FROM Shipments WHERE On_time = 1 GROUP BY ID_number


 
I strongly recommend that you make a greater effort to trap errors in you MySQL-accessing code.

By trapping the return of the line you've posted, you could know whether the query worked programmatically. And if it did not, printing out the return of mysql_error() might give you some insight as to what went wrong. ______________________________________________________________________
TANSTAAFL!
 
Thanks Piti!!! Sleipnir214 my boss just gave me this job and he knew that I dont know anything about SQL so blame him :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top