MySQL table value execution - mysql

I am doing a simple execution in MySQL workbench, the syntax is correct but nothing is happening.
select first name from employees;
only that but nothing is happening on the table. can someone what might be the problem?

Related

Insert into MySQL from MS SQL

I work on a SQL Server 2016. In this Server has a linkedserver connection to MySQL. Now I want to insert from a local mssql table to a MySQL table.
My code is:
INSERT OPENQUERY (
MYSQL_BEWERTUNG
,'SELECT PERSONALNR, EINSATZSART, KUNDENNR FROM tb_bewertung'
)
SELECT b.PERSONALNR
,b.DATUMVON
,b.KUNDENNR
FROM ext_bewertungen b
After that execution, I get an message that 136 rows are effected.
If I look into the MySQL table, I can't find the new rows. But if I look from the MS SQL server with
SELECT PERSONALNR
,EINSATZSART
,KUNDENNR
FROM OPENQUERY(MYSQL_BEWERTUNG, 'SELECT PERSONALNR, EINSATZSART, KUNDENNR
FROM tb_bewertung')
ORDER BY 1;
the new rows were shown.
Could someone explain me what am I doing wrong?
Thanks a lot!
Solved problem, the t-sql is right, my IT change the webserver and change in my holidays my linkedserver also, thats why i did not see any changes... thanks #MandyShaw for the idea if I am on the wrong server =)

MySQL UPDATE statement is throwing "Column count doesn't match value count" error

(NOTE: I know this is an error that's commonly asked about, but most of the time, the issue is in an INSERT statement. I couldn't find a question on this website where this error happened during an UPDATE.)
I have a table in MySQL (InnoDB / v. 5.7.19) called RESULTS which has, among others, two columns called TYPE and STATUS. Both are of type ENUM, with PASS, FAIL and IGNORE being the supported values in both. I'm trying to run this UPDATE statement on that table, using Workbench (also tried the same directly on the DB machine, using the mysql command):
update `RESULTS` set `TYPE`='IGNORE' where `STATUS`='IGNORE';
I'm getting this error:
Error Code: 1136. Column count doesn't match value count at row 1
Changing the single quotes to double quotes didn't help. I'm able to run this query successfully:
select count(`TYPE`) from `RESULTS` where `STATUS`='IGNORE';
I'm probably making a silly mistake here, but can anyone point out what's wrong with the UPDATE statement?
As requested I am posting it as an answer.
The error basically is self-explanatory like performing an operation on set of attributes but the values provided in the query are not enough. But in your case, you are performing an update operation with all attributes and their values and still, this error appears it may be a case that there is some trigger is registered for this table probably on before/after the event, If that is the case you need to update or remove that trigger if no needed.

MySQL inserting with select max(`Column`)+1 on possibly empty results

I've seen a lot of questions along the same-ish lines as mine, but they're just not quite exactly the same issue as me.
Here's my query:
insert into`quotes`(`QuoteID`,`QuoteRequestID`,`Number`,`UserID`,`Viewed`,
`_Latest`)
select uuid(),uuid(),
ifnull(max(`quotes`.`Number`),0)+1,'Some User ID',1,1
from`quotes`
join`quoterequests`using(`QuoteRequestID`)
where`quoterequests`.`UserID`='Some User Other ID';
And this is the error I'm getting:
Error Code: 1048. Column 'QuoteID' cannot be null
So my guess is that the select statement isn't returning anything, but how can that be since I'm using max() in my query?
Sure enough, if I remove the insert part and just run the select statement by itself, then I do get the expected results, with the new UUIDs (definitely not a null value) and all. What is happening here? Is this a bug with MySQL? My MySQL version is 5.7.14;
EDIT
So I have figured out if I wrap the select in another select, it now works as expected. Not sure if that's a solution or a workaround though, but it did get my query working.
it looks like you might have some trigger which generates the error - that is the only explanation I can think about.

Cannot delete record from MySQL. Error says column does not exist, when it clearly does

This is very strange..
I'm using PHPMyAdmin to view a table. [edit: Does the exact same thing in SQLYog.] I select one of the records in that table, and click "Delete". I then get an error saying that the column (in this case "users_id" which is an auto-increment primary key) does not exist. Yet.. when I run a select query for that same info, it returns the record fine.
So, here's the SELECT query I'm using that finds the record perfectly:
select * from users where users_id = 53
No quotes, nothing. And it returns the record with no problem. I would show you in a screen capture, but even though I have the reputation, the system isn't allowing me to post images. (ugh)
However, do this either by clicking "Delete" and "GO", or by entering SQL directly:
delete from users where users_id = 53
.. and you get an error:
Error
SQL query:
DELETE FROM `goat-dev`.`users` WHERE `users`.`users_id` =53
MySQL said: Documentation
#1054 - Unknown column 'users_id' in 'where clause'
So clearly something is off... and I just don't see what. Any suggestions?
I'm logged in as "root" with full permissions. I've quadruple-checked to be sure I have no limits on my permissions (not sure how root could).
Ok.. going to close this out. Found the problem. But left it up here for a moment to share the answer for the benefit of others.
There was a trigger that was not working properly. The trigger was actually removing data from another table if a record in this table was deleted. Apparently there was an error in that trigger. Yet.. MySQL wasn't quoting the error - rather just throwing an error on this delete. Kinda not well behaved. But.. thought this may help someone else having this problem.
Hope this is at-least a little helpful.

#1054 - Unknown column 'tidbitz' in 'field list'

Via phpmyadmin I dropped the column 'tidbitz' from a table.
Now any time I try to write to that table I get this error. The column is gone and it's not included in any of the queries that I am running. I know the syntax is correct for my queries. I can't even edit data using phpmyadmin, I still get this error.
I have tried: restarting the mysql server, restarting apache, defragmenting and optimizing the table...
Why is this ghost column sticking around?
Just encountered the same problem. In my case it was caused by an insert trigger that was running a query which was using the no-longer-existing column.
I ended up fixing my problem by creating another identical table, writing all of the data from table one to table two, dropping table one, and renaming table two to table one.
So, the problem is fixed, but I'm still curious to know if anyone has encountered this before and what the root cause is.
Thanks!