MySQL simple query syntax error - mysql

When I try to run this simple script:
INSERT INTO landlord (full_name, tel_number, email, password) VALUES
('landlord1', '12345', 'landlord1#email.com', 'pass1'),
('landlord2', '12345', 'landlord2#email.com', 'pass2'),
('landlord3', '12345', 'landlord3#email.com', 'pass3');
I got an error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO landlord (full_name, tel_number, email, password) VALUES
('landlor' at line 2
What's wrong with it?

Related

Syntax error when adding an array in the entity - Node.js, TypeORM, MySQL

I'm using Node.js and TypeORM with MySQL but the error shows MariaDB I don't know why. I'm trying to use array in User entity and this must be the error
ERROR:
QueryFailedError: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version
for the right syntax to use near '' at line 1",
sqlState: '42000',
index: 0,
sql: 'ALTER TABLE `user` ADD `favorites` text NOT NULL DEFAULT '
},
code: 'ER_PARSE_ERROR',
errno: 1064,
sqlMessage: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 1",
sqlState: '42000',
index: 0,
sql: 'ALTER TABLE `user` ADD `favorites` text NOT NULL DEFAULT '
}
The columns causing the error:
#Column({ type: "simple-array", default: [] })
favorites: string[];
#Column({ type: "simple-array", default: [] })
cart: string[];
You can't have default value for column type text in mysql. Remove the default parameter in the column options and the query should work.
If you still want to have any default value set, you can write a native mysql trigger or use typeorm #AfterInsert hook to set the value of columns cart or favorites just after they're inserted in the database.

Mysql. JSON. Why I get - Error Code: 1064

Simple table:
CREATE TABLE `LocalTest` (
`mainJson` json NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
Attempt to insert json value:
insert into `LocalTest` (mainJson) values ('{ "key": "value" }')
As result error:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Error Code: 3140. Invalid JSON text: "The document root must not be followed by ' at line 3
What wrong with this simplest script?

wpdb : select from custom table : sql error

I'm getting an error while trying to query a custom table using the wpdb class. Here is my code :
global $wpdb;
$dates_bloquees = $wpdb->query(
$wpdb->prepare( "SELECT datesbloquees FROM $wpdb->datesbloquees WHERE idproduit = '%d' ", $postid ) );
Error message :
WordPress database error: [You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'WHERE idproduit = '1'' at line 1]
Can someone tell me what I'm doing wrong?
Thank you for your help,
François

MySQL Export error using Replace

SELECT `template_id`, replace(template_code,"AT -","DE -") as
template_code, `template_text`, `template_styles`, `template_type`,
`template_subject`, `template_sender_name`, `template_sender_email`,
`added_at`, `modified_at`, `orig_template_code`, `orig_template_variables`
FROM `core_email_template` WHERE template_code like "%AT - %"
This query it works and returns me some data that I want to export it. But when I do that from phpmyadmin I received this error:
Error reading data: (#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the
right syntax to use near 'FROM WHERE
(`core_email_template`.`template_id` = 27) OR (`core_email_template' at
line 1)
What should I have to do to make this work ? thx

Following Sharetribe install instructions and getting error "ERROR 1064 (42000): You have an error in your SQL syntax;"

I'm a complete nubie to Ruby but have managed to get this far following these instructions:
https://github.com/sharetribe/sharetribe
But a straight copy/paste of this code into terminal results in errors. Any ideas?
c = Community.create(:name => "your_chosen_name_here", :domain => "your_chosen_subdomain_here")
tt = c.transaction_types.create(:type => "Sell",
:price_field => 1,
:price_quantity_placeholder => nil);
tt_trans = TransactionTypeTranslation.create(:transaction_type_id => tt.id,
:locale => "en",
:name => "Sell",
:action_button_label => "Buy");
ca = c.categories.create;
ca_trans = CategoryTranslation.create(:category_id => ca.id,
:locale => "en",
:name => "Items");
CategoryTransactionType.create(:category_id => ca.id, :transaction_type_id => tt.id)
Errors are:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'c = Community.create(:name => "marketfarm", :domain => "marketfarm")
c = Communi' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tt_trans = TransactionTypeTranslation.create(:transaction_type_id => tt.id,
:lo' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ca = c.categories.create' at line 1
etc.
Thanks for trying out Sharetribe!
First of all, we have updated the installation instructions. New installation instructions do not require this step.
In you case I guess there's somekind of copy/paste error there. Maybe you could try first copy/paste the command to a text editor (i.e. Notepad) and remove the line breaks and make the commands single line. I have notice that sometimes console doesn't understand multiline pasted commands.
I guess you are using any other database like sqlite or postgresql than Mysql.
Sharetribe only supports with Mysql database.
Thanks