You can run command:docker cp {file.sql} {id image}:/{file.sql}open mysql cli and run this command:mysql -u{your_username} -p{your_password} {your_database_name} < {file.sql}
You can't use arbitrary statements in the THEN part of a MERGE, the syntax is quite specific about what you are allowed to do.
If you want to THROW on such rows then just use a IF EXISTS... WHERE NOT...
The problem is that you have a self-referencing foreign key, which is preventing you deleting this row because there are child rows dependent on it. The UPDATE statement isn't helping as that will onl...
You can try to use indexOf keyword.
SELECT name
FROM table
WHERE id IN (5, 3, 7, 8, 11, 14, 54)
ORDER BY indexOf([5, 3, 7, 8, 11, 14, 54], id);
This gives you the result in the order specified in the...
Please note that the invoice_date is in varchar. I intentionally did that.
Please don't store your dates as text. And if you must do that, you should at least store in YYYY-MM-DD iso format so that...
SELECT state, percent_alcohol_impaired
FROM playground.bad_drivers
WHERE percent_alcohol_impaired > 1.2 * (SELECT AVG(percent_alcohol_impaired) FROM playground.bad_drivers)
LIMIT 100;
You should...
Something like this mayhaps:
DECLARE @cols AS NVARCHAR(MAX), @cols2 NVARCHAR(MAX), @sql AS NVARCHAR(MAX);
SELECT *
INTO #data
FROM (
VALUES (1, N'A', N'H', N'J')
, (2, N'B', N'I', N...
I have a query where I am checking for the first instance of a status.
Seems like you're checking for the latest instance of a status.
It seems like the problem statement can be simplified to:
Find...
We can take a union of the two tables and then aggregate by name:
SELECT name, id, GROUP_CONCAT(course) AS courses -- see note below
FROM
(
SELECT name, id, course FROM TableA
UNION ALL
S...
Lost your password? Please enter your email address. You will receive a link to create a new password.
Donate
Thank you for visit here to donate to us, you think it's just a cup of coffee, but with us, it's really meaningful and contributes to help this blog grow more and more.
You can support us in one of the ways below: