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

load inline file

Status
Not open for further replies.

manking

MIS
Jan 29, 2003
28
US
I am trying to load a file. I get the file to load but the category_id and supplier id load blank entries. Can someone tell me what I am doing wrong in the statement below.

LOAD DATA INFILE 'c:/inventory.csv' INTO TABLE pos.items
fields terminated by ',' IGNORE 1 LINES
(@a,@b,ITEM_NAME,@f,@c,DEPOSIT,@g,supplier_catalogue_number,Model,SERIAL_NUMBER,@d,@e)
set
category_id=(SELECT id as aa FROM `pos`.`categories` where category like '%@a%'),
brand_id = 1,
supplier_id = (SELECT id FROM suppliers where supplier like '%@e%'),
quantity = 0,
tax_percent = 0,
total_cost =@g * 1,
buy_price = 0,
unit_price = @g
;

 
In the SET statements, I think you need the CONCAT function to make the LIKE clauses work. Also, I think you need to put a @ infront of the variable names.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top