Hey so I'm trying to set up an export data task in DBeaver, because I want to export some data to another database and I want to query the date in beforehand. So I'm trying to use this SELECT statement
SELECT *
FROM resource
WHERE assignedteamid = 2 AND active;
which works fine on its own but when I'm trying to add this query in the Task setup screen and click on continue I get this Error
Can't get attributes from `SELECT * FROM resource WHERE assignedteamid = 2 AND active;`
Reason: SQL 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 'LIMIT 0, 1' at line 4
I already tried to change up the query but I have no clue what I need to do to fix this problem. I appreciate any help.
Thank you!
I like to get the id of the record that's been inserted by a statement as a result of that statement. I know about SELECT LAST_INSERT_ID(); but can not use it in my scenario because LAST_INSERT_ID() works on a per-connection-basis and I am currently using a convenient function in my framework to access the db - but that convenience implies that the connection only exists during execution of that statement - so I'm wondering if there is a syntax as in Microsoft SQL Server as shown in the title?
In my environment, I am building the command looks like this:
INSERT INTO Bookings (Status,YEarlyBird,YDays,YHotel,YBanquet,Name,Company,Address,Town,Region,Postcode,CountryCode,Second
Name,SecondEmail,RoomType,SpouseMealPlan,Notes,Conference_VAT,Accommodation_VAT,Conference_id,InvoiceAmount,Conferen
ceGross,Accomodation,SpouseGross,SpouseNet,TotalGross,TotalNet,ConferenceNet,Courses) VALUES (:<C1:,:<C1:,:<C6:,:<C
6:,:<C1:,:<C12:,:<C28:,:<C15:,:<C7:,:<C5:,:<C5:,:<C2:,:<C1:,:<C1:,:<C15:,:<C3:,:<C1:,:<F:,:<F:,:<I:,:<F:,:<F:,:<F:,:
<F:,:<F:,:<F:,:<F:,:<F:,:<C1:);SELECT LAST_INSERT_ID();
(the :<:-stuff are placeholders for Bind-variables)
If a ran the INSERT on its own, it works. If I append the SELECT LAST_INSERT_ID() as shown, I get:
[MySQL][ODBC 5.3(w) Driver][mysqld-5.7.18-log]You have an error in your SQL syntax; check the manual that corresponds to y
our MySQL server version for the right syntax to use near 'SELECT LAST_INSERT_ID()' at line 1
P.S: using that convient way to access the DB is perfectly ok in my use-case because the DB is written once only - exactly with the statement i am working on.
Someone gave me this query to delete community from a database on my server using phpMyAdmin, it worked when he use it so I asked him to send it to me, but I get a error
MySQL said:
Documentation
#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 '"SELECT * FROM `connections` WHERE 1" :
delete from connections where communit' at line 1
I did a search on the error but could not figure it out.
"SELECT * FROM `connections` WHERE 1" :
delete from connections where community="XYZ"
You should separate your queries with ; and not :
The error you are receiving as you've shown it is because this line is incorrect:
SELECT * FROM `connections` WHERE 1"
First because it's ending in an unnecessary double quotation mark. MySQL does not use double quotes but single quotes, and even still the other single quote is not there to match it.
The single quotes are also a problem for community="XYZ", this should read: community = 'XYZ'
Secondly, you don't have a condition for your where statement, you must be missing something like:
WHERE columnName = 1;
If you were trying to select everything from connections, you can just remove that where clause all together.
EDIT
In addition, MySQL queries are separated by a semi-colon, not a colon, so MySQL will not realize you are trying two different queries.
Really, what could possibly be wrong?! It does not get any more simple - the entire query:
line 1: use foo
line 2:
line 3: select * from test_table_1;
Error Code:
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 'select * from test_table_1' at
line 3 0.002 sec
The line numbers are for reference only - there not actually in the query window.
I'm trying to run this extremely simple query in MySQLWorkbench and it's throwing a syntax error.
Try adding a semicolon:
use foo;
Without semicolon both statements will treat as single one.
By adding semicolon MySQL will treat both statements as multiple queries.
Try using
use foo;
/*and then*/
select * from foo;
I'm using Update videos Set views = views + 1 Where video_id='$id', but MySQL give me back error 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 ' 8' at line 1
What can cause it?
Most likely $id is not what you expect it is. I imagine the query that is coming through looks something like
update videos set view = views + 1 where video='' 8'';
Note: Those are two single quotes on either side of the 8.
To confirm this you have a couple options.
Turn on general query logging, as a super user (root) from the mysql command prompt run
set general_log_file='/tmp/mysql.log';
set general_log ='on';
Now every single query that gets sent to mysql will show up in /tmp/mysql.log (Note this can quickly grow very large so don't leave it on after you're done debugging).
App logs
Do you have any kind of logging frame work going on? Before your actual call to execute the query, log the value of ($id). For a poor mans logging you could do something like
file_put_contents('/tmp/debug.txt', date("Y-m-d H:i:s")." id is [$id]\n",FILE_APPEND);