Home > database >  Turn to the SQL
Turn to the SQL

Time:09-18

Several records in a table have, need to go under the name again after heavy according to the latest create_time took out all of the same name a
 SELECT 
Associates. The username,
Associates. Mobile,
Associates. Sex,
Associates. Id_card,
Associates. Worker_source,
C.com pany_name,
B.N AME,
A.S TATUS
The FROM
H_worker_contract a
RIGHT JOIN h_worker associates ON aleem walji orker_id=associates. Id//need according to the requirements of this table out I said above
LEFT the JOIN t_company c ON a.com pany_id=c.i d
LEFT the JOIN h_job b ON a. ob_id=b.i d


Excuse me, on the basis of the SQL should be how to change

CodePudding user response:

Is the username will h_worker to weighing out all of the newly created with the same one

CodePudding user response:

Have not understand can ask, may I express is not very clear

CodePudding user response:

No one will be,,

CodePudding user response:

 SELECT * 
The FROM (
SELECT
ROW_NUMBER () OVER (PARTITION BY associates. The username ORDER BY create_time DESC) AS rids,
Associates. The username,
Associates. Mobile,
Associates. Sex,
Associates. Id_card,
Associates. Worker_source,
C.com pany_name,
B.N AME,
A.S TATUS
The FROM
H_worker_contract a
RIGHT JOIN h_worker associates ON aleem walji orker_id=associates. Id - according to the requirements of this table out I said above
LEFT the JOIN t_company c ON a.com pany_id=c.i d
LEFT the JOIN h_job b ON a. ob_id=b.i d
) AS tt
WHERE tt. Rids=1

CodePudding user response:

reference 4 floor gypsy song response:
 SELECT * 
The FROM (
SELECT
ROW_NUMBER () OVER (PARTITION BY associates. The username ORDER BY create_time DESC) AS rids,
Associates. The username,
Associates. Mobile,
Associates. Sex,
Associates. Id_card,
Associates. Worker_source,
C.com pany_name,
B.N AME,
A.S TATUS
The FROM
H_worker_contract a
RIGHT JOIN h_worker associates ON aleem walji orker_id=associates. Id - according to the requirements of this table out I said above
LEFT the JOIN t_company c ON a.com pany_id=c.i d
LEFT the JOIN h_job b ON a. ob_id=b.i d
) AS tt
WHERE tt. Rids=1


Mysql like write so bad...

CodePudding user response:

Really don't come out

CodePudding user response:

 
SELECT
Associates. The username,
Associates. Mobile,
Associates. Sex,
Associates. Id_card,
Associates. Worker_source,
C.com pany_name,
B.N AME,
A.S TATUS
The FROM
(select * from h_worker_contract d
Where not the exists (select 1 from h_worker_contract where d.w orker_id=worker_id and create_time & gt; , dc reate_time)) as a
RIGHT JOIN h_worker associates ON aleem walji orker_id=associates. Id//need according to the requirements of this table out I said above
LEFT the JOIN t_company c ON a.com pany_id=c.i d
LEFT the JOIN h_job b ON a. ob_id=b.i d

CodePudding user response:

Mysql high version, that is, 8.0 + can have similar wording,
Low ought to be like the other way,
  • Related