Can't disable SQL parenthesis auto-complete in Eclipse - mysql

I've been through the preferences in Eclipse, and I can't figure out how to disable code completion for files like .sql
Take this for example:
WHERE
`key` = ''
AND key_expires > CURRENT_TIMESTAMP
When I edit the WHERE clause, I get this:
WHERE
()`key` = '' OR `key` IS NULL)
AND key_expires > CURRENT_TIMESTAMP
I've tried turning off every option for parens, but to no avail.

in the preferences go to Data Management -> SQL Development -> SQL Editor
Click on the 'Typing' tab, Uncheck 'Close parentheses' and click Apply/OK
I hope that works for you, it does for me.

Related

Custom Delimiter in SQL Server Management Studio does not work

I'm trying to change my delimiter to a pipe:
I have restarted SQL Server Management Studio. However, I keep having the csv file with the previous delimiter.
Is it necessary to do something else?
You are setting custom delimiter for Results to Text option. But, you are trying to save results in the Results to Grid option.
If you are having Results to Text option (Shortcut Ctrl + T), you will get the result properly. You can copy and save the result accordingly.
update:
To turn off rowcount
SET NOROWCOUNT ON -- Add this setting before SELECT query
SELECT ...
Or in the
Tools > Options > Query Execution > SQL Server > Advanced > check SET NOROWCOUNT
To turn off completion time
Tools > Options > Query Execution > SQL Server > Advanced. Uncheck the
Show Completion Time checkbox

Why phpStorm marks an error on valid query

I have a query:
$this->source->exec("UPDATE `account` AS `m1`,
(SELECT `m2`.`id`
FROM `account` AS `m2`
WHERE `m2`.`userid` = ? AND `m2`.`demo` = 0
ORDER BY `m2`.`date` DESC LIMIT 1) AS `m2`
SET `m1`.`default` = '1'
WHERE `m1`.`id` = `m2`.`id` AND `m1`.`demo` = 0", $user_id);
Now, phpStorm is trowing an error for the ORDER BY in the subquery. The query works perfectly when the code is run. I set MySQL as the SQL dialect in phpStorm.
The error is:
GROUP or HAVING expected, ORDER got.
How can I fix this error?
actually phpstorm recognize this symbol as invalid key when using with php, cz of php doesn't know aboutsql` use
If you check you sql with index.sql its show like this (without errors)
so just create test page with test.sql and copy your sql code.
then above of the code you can see orange color tab shows(check below image)
click Configure Data Source
and click MySQL in left side panel(below image)
and then click download in bottom of the panel(below image)
It will download file(s) relevant your versions
and click ok.
now delete the index.sql and you can use as same without error.
I have tested and work fine to me

MySQL Workbench - How do I set a value to NULL using the GUI? [duplicate]

I'm using the MySQL Query Browser (part of the MySQL GUI Tools) and need to change a field to NULL, but I can't figure out how to do it - if I delete the value it tries to update it to ''. Typing "NULL" makes it try to update to 'NULL' (a string).
I know I could just write a query to do it, but that defeats the entire purpose of the tool, no?
In MySQL Query Browser, right click on the cell and select 'Clear field content' while the focus is in another cell.
In MySQL Workbench, right click on the cell and select 'Set Field to NULL'.
In MySQL Workbench, with the cell selected, press Shift + Delete
Tested on 6.3.4.0
Right-click on that column and select the
'Set field to Null'
option from the context menu.
Removing the contents:
This works for some tools (sorry to hear it doesn't for yours).
This may not appear as null but will when you perform a query.
Shift + Delete
work well in MySql Workbench 8
I'd try Ctrl-0 (zero), because that works in some tools.

Update query failing with error : 1175

I am trying to update a table using the following query
update at_product A join
(
SELECT atbillfields.billeditemguid,count(*) AS numberOfPeopleBought
,sum(atbillfields.billeditemqty) AS soldquantity
FROM jtbillingtest.at_salesbill atsalesbill
JOIN jtbillingtest.at_billfields atbillfields
ON atsalesbill.billbatchguid=atbillfields.billbatchguid
WHERE atsalesbill.billcreationdate BETWEEN '2013-09-09' AND date_add('2013-09-09', INTERVAL 1 DAY)
GROUP BY atbillfields.billeditemguid) B ON B.billeditemguid = A.productguid
SET A.productQuantity = A.productQuantity - B.soldquantity
But, getting the following exception:
Error Code: 1175. You are using safe update mode and you tried to
update a table without a WHERE that uses a KEY column To disable safe
mode, toggle the option in Preferences -> SQL Queries and reconnect.
When I gave a where clause with the update like A.productQuantity = 1, it updated that particular.
Can someone point why I am unable to execute the query and how to solve the issue?
Have a look at:
http://justalittlebrain.wordpress.com/2010/09/15/you-are-using-safe-update-mode-and-you-tried-to-update-a-table-without-a-where-that-uses-a-key-column/
If you want to update without a where key you must execute
SET SQL_SAFE_UPDATES=0;
right before your query.
Another option is to rewrite your query o include a key.
This error means you're operating in safe update mode and therefore you have two options:
you need to provide a where clause that includes an index for the update to be successful or
You can disable this feature by doing SET SQL_SAFE_UPDATES = 0;
You can try on MysqlWorkbench
Go to Edit --> Preferences
Click "SQL Editor" tab and uncheck "Safe Updates" check box
Query --> Reconnect to Server (logout and then login)
I hope it is helpful for you.
In MySQL 5.5, if you're using MySQL Workbench then
Go to Edit --> Preferences
Click "SQL Queries" tab and uncheck "Safe Updates" check box.
Query --> Reconnect to Server (logout and then login)
This works.
In my case, I disable checking the foreign key using this Mysql command:
SET FOREIGN_KEY_CHECKS=0;

How to make a field NULL using MySQL GUI Tools?

I'm using the MySQL Query Browser (part of the MySQL GUI Tools) and need to change a field to NULL, but I can't figure out how to do it - if I delete the value it tries to update it to ''. Typing "NULL" makes it try to update to 'NULL' (a string).
I know I could just write a query to do it, but that defeats the entire purpose of the tool, no?
In MySQL Query Browser, right click on the cell and select 'Clear field content' while the focus is in another cell.
In MySQL Workbench, right click on the cell and select 'Set Field to NULL'.
In MySQL Workbench, with the cell selected, press Shift + Delete
Tested on 6.3.4.0
Right-click on that column and select the
'Set field to Null'
option from the context menu.
Removing the contents:
This works for some tools (sorry to hear it doesn't for yours).
This may not appear as null but will when you perform a query.
Shift + Delete
work well in MySql Workbench 8
I'd try Ctrl-0 (zero), because that works in some tools.