| |

VerySource

 Forgot password?
 Register
Search
View: 806|Reply: 3

SQL query problem

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-9 15:00:01
| Show all posts |Read mode
I now use this statement to query a recordset,
select a. * from tablename a where datetimecolumn = (select max (datetimecolumn) from tablename where username = a.username)

Then I have to do a join condition with a table called erid. In the query result, username = erid.username
After I tried to do jion directly, I still only get the results of the previous query. Everything in the erid table comes out. Isn't it written like this? How to write it?
Reply

Use magic Report

0

Threads

8

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-11 18:00:01
| Show all posts
Is this right?
select a. *, e. * from tablename a
join erid e on e.username = erid.username
where a.datetimecolumn = (select max (datetimecolumn) from tablename where username = a.username)
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-4-6 22:00:01
| Show all posts
select a. *, e. * from tablename a
right join erid e on e.username = erid.username
where a.datetimecolumn = (select max (datetimecolumn) from tablename where username = a.username)
?
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-17 20:00:01
| Show all posts
select a.*,b.* from tablename a
right join erid b on a.username=b.username
where a.datetimecolumn=(select max(datetimecolumn) from tablename where username=a.username)
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list