| |

VerySource

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

Where am I wrong with this sql statement?

[Copy link]

2

Threads

6

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 United States

Post time: 2020-2-11 01:00:01
| Show all posts |Read mode
Load the statistics into the temporary table tmptab, and then select the unique records to insert into the table tongji

insert into tongji
select * from tmptab
where cardnum, xfdate, xftime
not in (select cardnum, xfdate, xftime from tongji);
Reply

Use magic Report

0

Threads

4

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-4-6 20:30:01
| Show all posts
not in cannot use multiple fields
You can choose a unique key as the not in condition
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-9 12:30:01
| Show all posts
insert into tongji select tmptab. * from tmptab left outer join tongji on tmptab.cardnum = tongji.cardnum and tmptab.xfdate = tmptab.xfdate and tmptab.xftime = tongji.xftime where tongji.cardnum is not null
It's roughly like this, try it.
Reply

Use magic Report

0

Threads

100

Posts

53.00

Credits

Newbie

Rank: 1

Credits
53.00

 China

Post time: 2020-4-10 09:15:01
| Show all posts
The last condition is wrong, amended as follows:
insert into tongji select tmptab. * from tmptab left outer join tongji on tmptab.cardnum = tongji.cardnum and tmptab.xfdate = tmptab.xfdate and tmptab.xftime = tongji.xftime where tongji.cardnum is null
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