How to select unique records from a table using a SQL query?

|
ruydar 2022-06-06 21:33:35
private_String 2022-04-07 13:56:26
Someone who can help me? I can also do a videocall
Iā€™m using hibernate, struts2 and log4j

Hi how convert MySQL to HQL

piyush 2022-06-06 22:32:38
Need help me too
Alejandro 2022-06-07 00:03:46
i think i can help you
Alejandro 2022-06-07 00:45:14
let me know if still need help
Mangesh Panchal 2022-06-07 06:55:37
Anyone there who can help me to setup MySQL on local machine as a consultant.
Liran 2022-06-07 10:13:24
i need some help writing a stored procedure to archive old rows (delete and insert to archive tables)
i want to run a select that will return users ids that were deleted the past 24 hours, and then archive all their rows from tables according to this id.
how can i do that?
svart 2022-06-07 10:55:17
Liran 2022-06-07 10:13:24
i need some help writing a stored procedure to archive old rows (delete and insert to archive tables)
i want to run a select that will return users ids that were deleted the past 24 hours, and then archive all their rows from tables according to this id.
how can i do that?

you can pt-archiver from percona toolkit

Liran 2022-06-07 11:48:52
i wrote something like this
Liran 2022-06-07 11:48:58
“`
DELIMITER $$
CREATE PROCEDURE _tmp_update_address()
BEGIN
DECLARE cursor_List_isdone BOOLEAN DEFAULT FALSE;
DECLARE cur_userId, cur_personId INT;
DECLARE cur_email VARCHAR(250) DEFAULT ”;

DECLARE cursor_List CURSOR FOR
SELECT id from test2.users where id=1;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET cursor_List_isdone = TRUE;

OPEN cursor_List;

loop_List: LOOP
FETCH cursor_List INTO cur_userId;
IF cursor_List_isdone THEN
LEAVE loop_List;
END IF;

INSERT INTO test2.users_archive select * from test2.users;
delete from test2.users where id=cur_userId
END LOOP loop_List;

CLOSE cursor_List;
END $$

DELIMITER ;
“`

Liran 2022-06-07 11:49:21
but for some reason i get error like this:
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 LOOP loop_List;

CLOSE cursor_List’ at line 24

svart 2022-06-07 12:03:10
Liran 2022-06-07 11:49:21
but for some reason i get error like this:
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 LOOP loop_List;

CLOSE cursor_List’ at line 24

“;” should be after the statement “delete from test2.users ….”

Liran 2022-06-07 12:03:25
svart 2022-06-07 12:03:10
“;” should be after the statement “delete from test2.users ….”

yeah šŸ™ i just saw that!

Liran 2022-06-07 12:03:26
thanks!
Brtarikan 2022-06-07 15:54:43
mysql_en-21393.jpg
how can i solve this error
svart 2022-06-07 16:58:51
Brtarikan 2022-06-07 15:54:43
how can i solve this error

Check mysql error log. There will be some hints

Nanivikas 2022-06-07 18:33:50
Hi team, i need your input for MySQL query

i have two tables A and B

A has transaction date colum
B has start date and end date

I need to get transaction date in between Start date and end date

When i used between the execution time is High.

Is there any way to optimise the query. Am using only one left join.

Swapnil 2022-06-07 18:36:59
Nanivikas 2022-06-07 18:33:50
Hi team, i need your input for MySQL query

i have two tables A and B

A has transaction date colum
B has start date and end date

I need to get transaction date in between Start date and end date

When i used between the execution time is High.

Is there any way to optimise the query. Am using only one left join.

try date>= and date <=

Nanivikas 2022-06-07 18:40:02
Swapnil 2022-06-07 18:36:59
try date>= and date <=

U mean i can give

Transaction date >= start_date <=End_date?

Swapnil 2022-06-07 18:46:17
yes
Nanivikas 2022-06-07 18:48:22
Swapnil 2022-06-07 18:46:17
yes

Syntax error

Swapnil 2022-06-07 18:50:09
Nanivikas 2022-06-07 18:48:22
Syntax error

put and keyword in between

Swapnil 2022-06-07 18:50:15
Swapnil 2022-06-07 18:36:59
try date>= and date <=

see this

Satish R 2022-06-07 19:17:44
Hi team
Satish R 2022-06-07 19:18:38
I need MySQL admin training can any one suggest the training institute details
. 2022-06-07 19:37:53
did any one have mysql book as pdf
Vinayak Madiwalar 2022-06-07 20:34:30
āœ‹ hi
Vinayak Madiwalar 2022-06-07 20:34:45
We have deployed zabbix server
Vinayak Madiwalar 2022-06-07 20:35:39
In my SQL “history_uint.ibd“ day by day the table size is growing now its 42G and same for “history.ibd“ size “12G“ and storage size is getting full, can you suggest what needs to be done for this.
Vinayak Madiwalar 2022-06-07 20:41:38
Vinayak Madiwalar 2022-06-07 20:35:39
In my SQL “history_uint.ibd“ day by day the table size is growing now its 42G and same for “history.ibd“ size “12G“ and storage size is getting full, can you suggest what needs to be done for this.

Please help it’s quite arrgency

svart 2022-06-07 22:26:40
Vinayak Madiwalar 2022-06-07 20:35:39
In my SQL “history_uint.ibd“ day by day the table size is growing now its 42G and same for “history.ibd“ size “12G“ and storage size is getting full, can you suggest what needs to be done for this.

you can partition history and trends tables. then drop too old partitions daily to keep enough disk space

Alejandro 2022-06-08 03:07:08
Maybe i can help you, whats the issue?
Alejandro 2022-06-08 03:15:55
Nanivikas 2022-06-07 18:33:50
Hi team, i need your input for MySQL query

i have two tables A and B

A has transaction date colum
B has start date and end date

I need to get transaction date in between Start date and end date

When i used between the execution time is High.

Is there any way to optimise the query. Am using only one left join.

I have an issue similar and what i did is
Create a view with
Concat(id customer tab A, date formatted)
Union (id customer tab B, start date formmated)
Union (id customer tab B, end date formmated)

Create a new view linking
Above view with left (tab A with concat) and (tab B with concat)

Then use into the new view
The proper right and left to split the id and date, on where clouse

Seshu karthikk 2022-06-08 06:18:07
Hi good morning
Q . How to select unique records from a table using a SQL query?
Seshu karthikk 2022-06-08 06:18:43
. 2022-06-07 19:37:53
did any one have mysql book as pdf

For me also

Swapnil 2022-06-08 08:23:00
Seshu karthikk 2022-06-08 06:18:07
Hi good morning
Q . How to select unique records from a table using a SQL query?

Use distinct in select clause
Select distinct columnnames
from table

|