sql - MySql Error 1241 on Insert Statement -


this code, , giving me: "error code 1241. operand should contain 1 column(s)". have been staring @ few hours , cannot figure out causing it. can provide create table statement if help. additionally using mysql workbench 56.

sorry poorly formatted code, first post, if have broken rules please let me know. happy resubmit it.

old code:

    insert sales (sales_id, sales, salesman, customer, date, region)   values ( (null,null,null,...), (...),  ); 

corrected code:

insert sales (sales_id, sales, salesman, customer, date, region)  values   (null, 2456.00, 'barb', 'd-square', '2014/06/10', 'n reg'),   (null, 3894.00, 'barb', 'lowes', '2014/05/08', 'n reg'),   ...(last row); 

two things think clarify how fixed this. first, rearranged recommended in chosen answer, realized values statement had many parentheses.

it was: values ((first row),(second row),... );

but correct way actually: values (first row), (second row)... (last row);

i didn't realize input "bookends" of statement values ... and... ;

additionally dates formatted incorrectly, should have been yyyy/mm/dd instead of mm/dd/yyyy

thanks help! amazed @ how active , fast community is. guys life savers.

the problem insert have flipped data: insert expects values organized row-by-row, in table. provided data organized column-by-column.

once "flip" data put in right order, insertion work:

insert sales (sales_id, sales, salesman, customer, date, region) values     (null, 2456.00, 'barb', '06/10/2014', 'd-square', 'n reg') ,   (null, 3894.00, 'barb', '05/08/2014', 'lowes', 'n reg') ,   ... -- , on remaining 26 rows 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -