Ajuda com o erro SQL 1064

use bancoteste: create TABLE login{nome varchar(10),senha varchar(10)); INSERT into login VALUES (root´,root´); SELECT * from login

Galera boa tarde! Poderiam me ajudar a resolver esse problema aqui? grato. /* Erro SQL (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 ‘: create TABLE login{nome varchar(10),senha varchar(10))’ at line 1 */

Problema erro 1064 (42000) MYSQL

CREATE TABLE cliente( ID VARCHAR(100) AUTO_INCREMENT PRIMARY KEY, NOME VARCHAR(30), SOBRENOME VARCHAR(30), CPF INT(11), SEXO CHAR(1),  ); 

Erro (conforme descrito no título):

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 ‘)’ at line 8

Erro ao criar chave estrangeira estrangeira 1064

Alguem pode me ajudar a resolver? to tentando criar chave estrangeira e ta dando esse erro.

Executing SQL script in server ERROR: Error 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 ” at line 3 SQL Code: ALTER TABLE nippon.fotos_carros ADD COLUMN autos_idAutos INT(11) NOT NULL AFTER caminho, ADD INDEX fk_fotos_carros_autos_idx (autos_idAutos ASC) VISIBLE

MySQL Error 1064: You have an error in your SQL syntax


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 ‘WHERE _id IS NULL’ at line 2

SELECT * WHERE `_id` IS NULL 

Filename: views/backend/header.php

Line Number: 34

Código:

<?php $  name = $  this->db->get_where($  this->session->userdata('login_type'),  array($  this->session->userdata('login_type').'_id' => $  this->session-  >userdata('login_user_id')))->row()->name; echo $  name; ?> 

Mysql insert into table (table name is inside a variable) gives Error Code: 1064

The following procedure creates a new table and ‘should populate it with data from a select statement using INSERT INTO. If I test queries separately they work fine but in a form of bellow code it gives error.

CREATE DEFINER=`root`@`localhost` PROCEDURE `testing_temp_table_insert`   (    IN temp_table TEXT ) BEGIN  SET @temp_table = temp_table; SET @c = CONCAT('CREATE TABLE `',@temp_table, '` LIKE already_existing_table`'); PREPARE stmt from @c; EXECUTE stmt; DEALLOCATE PREPARE stmt;  SET @c = CONCAT('INSERT INTO `', @temp_table, '`                   (something, something_else)                  (SELECT (CASE WHEN length(ltrim(rtrim(some_table.something))) > 0                                 THEN some_table.something                                 ELSE '' END) as something,                          some_table.something_else                   FROM some_table;');  PREPARE stmt from @c; EXECUTE stmt;  END 

OK… if I separately test these queries:

This one successfully creates a temporary table under parameters ‘temp_table’ name:

SET @temp_table = temp_table; SET @c = CONCAT('CREATE TABLE `',@temp_table, '` LIKE already_existing_table`'); PREPARE stmt from @c; EXECUTE stmt; DEALLOCATE PREPARE stmt; 

But this one is giving me the error:

In its purest form like….

INSERT INTO already_existing_table  (something, something_else) (SELECT (CASE WHEN length(ltrim(rtrim(some_table.something))) > 0                THEN some_table.something                ELSE '' END) as something,         some_table.something_else  FROM some_table;'); 

works perfectly… but when written like this … (@temp_table is the same as already_existing_table)

 SET @c = CONCAT('INSERT INTO `', @temp_table, '`                   (something, something_else)                  (SELECT (CASE WHEN length(ltrim(rtrim(some_table.something))) > 0                                 THEN some_table.something                                 ELSE '' END) as something,                          some_table.something_else                   FROM some_table;');  PREPARE stmt from @c; EXECUTE stmt; 

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 ” END) as something

I get this is probably because of empty string ‘ ‘ which confuses the execution of the whole code but I can’t find the way around it as I’d like to leave the empty string option instead of null field.

Hopefully the question makes sense and attracts your attention. Thanks