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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unknown column name' in 'field list'

Status
Not open for further replies.

Shinju15

Technical User
May 10, 2012
2
0
0
CA
Hi everyone;

I am trying to update or inserting into a table depending of what is in the table. However, is gives me the error: Unknown column name' in 'field list'.

- Name is a column from the "Sold" table.
- I am trying to compare if that item is already in the table for the current month
If it is update sold table and increase the quantity of those items by one
else insert a new row in the table.​



Code:
SELECT *
FROM sold;
	
	IF name = v_ItemName AND time=DATE_FORMAT(NOW(), '%m') THEN
		UPDATE sold
		SET number_sold=number_sold + 1
		WHERE name =v_ItemName ;
	ELSE
		INSERT INTO sold
		(name, itemprice, quantity, time)
		VALUES
		(v_ItemName , v_itemprice, 1, DATEFORMAT(NOW(),'%m');
	END IF;
 
MySQL running on Linux is case sensitive so 'sold' and 'Sold' are not the same things.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top