I am trying to insert a record in mysql database using the following query, but getting the #1064-sql syntax error.
INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('4', 'Printer.TicketTotal', 0, LOAD_FILE('/home/anand/Openbravo-POS/main/src-pos/com/openbravo/pos/templates/Printer.TicketTotal.xml));
INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES('4', 'Printer.TicketTotal', 0, $FILE{/home/anand/Openbravo-POS/main/src-pos/com/openbravo/pos/templates/Printer.TicketTotal.xml});
You miss ' at the end of file name -
INSERT INTO RESOURCES(ID, NAME, RESTYPE, CONTENT) VALUES
('4',
'Printer.TicketTotal',
0,
LOAD_FILE('/home/anand/Openbravo-POS/main/src-pos/com/openbravo/pos/templates/Printer.TicketTotal.xml'));
Related
I have the following table data:
content,count
'a', '1'
'b', '2'
'c', '2'
'd', '2'
'content_name', '18'
'de', '2'
'dea', '2'
'deaasdfdsaf', '5'
'content_name', '17'
I would like to have the correct query for getting x (for example 4) rows with the biggest values in their content column
I have tried the answers given in:
Getting Top 3 from Mysql table based on Condition/Value
but it didnt work as i was expecting
it keeps giving me just the rows by their table location
any suggestions?
create table Test(content varchar(100),count integer );
insert into Test(content, count) values("a", 1);
insert into Test(content, count) values("b", 2);
insert into Test(content, count) values("c", 2);
insert into Test(content, count) values("d", 2);
insert into Test(content, count) values("content_name", 18);
insert into Test(content, count) values("de", 2);
insert into Test(content, count) values("dea", 2);
insert into Test(content, count) values("deaasdfdsaf", 5);
insert into Test(content, count) values("content_name", 7);
select * from Test
order by count desc
limit 4;
However, I am not quite sure what you mean by "biggest values in their content column", therefore I ranked by their count values.
If you are actually looking for the number of character within the content column, which was my initial impression reading your question:
Using Martin Stagl's post to create the example table .
select *, LENGTH(REPLACE(content, 'N', '')) as char_length from Test;
NOTE: If this is not working on the server, try replacing the LENGTH() function with LEN()
Fiddle: http://sqlfiddle.com/#!9/032d48/9
insert into foo_table (fname, lname, number)
values ('John', 'Doe', if(123 = 456));
For the above MySQL query, can somebody kindly explain what the if(123 = 456) is doing? I currently struggle to see an if statement without a body (i.e. if(condition){ // do something });
The query is syntactically not correct as per mysql version 8, The syntactically correct query is insert into foo_table (fname, lname, number) values ('John', 'Doe', if(123 = 456,1,2)). This will insert 1 if the condition (123 =456) is true, otherwise it will insert 2.
A standard insert MySQL query without any Subquery, but the MySQL tells me
Subquery return more than 1 row
INSERT INTO
db_novelV2.tbl_saler_todo
(
is_drive, customer_type, operator_id, STATUS, remark,
update_dt, receive_saler, src_id, come_dt, has_give_present,
TYPE, service_id, src_type, allot_saler, has_car_shuttle,
customer_id, session_id, arrive_dt, creater_id, leave_dt,
collector_id, store_id, allot_dt, add_dt
)
VALUES
(0, 0, 528, 0, '',NULL, 307,0, NOW(), 0, 1, 352,0,307, 0, 243465,2993333,NOW(), 528, NULL, 0,4, NOW(), NOW());
Check whether you have any INSERT triggers on your table, If so, disable any triggers before running your INSERT statement.
I have a .sql file that I am importing into my database using phpmyadmin. Each time I have been going through the long list of values and changing the ID so it doesn't conflict with another entry. Since I don't care what the ID is, is there any way to have that auto generated?
Example:
INSERT INTO `my_column` (`id`, `valueone`, `valuetwo`) VALUES
(1, 'some value A', 'some value B'),(2, 'some value C', 'some value D'),(3, 'some value E', 'some value F');
So in the above code, I don't want to type in the "1", "2", and "3".
Can I just leave this blank for it to auto generate? Or is there a symbol that I add instead?
Thanks!
Add AUTO_INCREMENT to id column and remove it from the insert Statement:
INSERT INTO `my_column` ( `valueone`, `valuetwo`) VALUES
( 'some value A', 'some value B'),( 'some value C', 'some value D'),(...
I am trying to insert a row into my table with the following query in ssms:
INSERT INTO [Reservation].[dbo].[Contacts]
([ContactID]
,[Name]
,[Phone]
,[Email]
,[QoowayUserName])
VALUES
(<"100", nvarchar(50),>
,<"Vincent Chase", nvarchar(50),>
,<"3103331234", nvarchar(50),>
,<"vincent_chase#hollywood.com", nvarchar(50),>
,<"Username", nvarchar(50),>)
GO
I get the error:
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near '<'.
I've also tried using single quotes. What am I doing wrong?
INSERT INTO Reservation.dbo.Contacts
(ContactID
,Name
,Phone
,Email
,QoowayUserName)
VALUES
('100'
,'Vincent Chase'
,'3103331234'
,'vincent_chase#hollywood.com'
,'Username')
You might need to remove the "dbo", like this:
INSERT INTO Reservation.Contacts
(ContactID
,Name
,Phone
,Email
,QoowayUserName)
VALUES
('100'
,'Vincent Chase'
,'3103331234'
,'vincent_chase#hollywood.com'
,'Username')