Sunday, 15 April 2012

MySQL 2 Tables, query before insert -



MySQL 2 Tables, query before insert -

i'm perplexed, here have.

two tables, 1 temporary, 1 permanent.

table temptable: city , state //- has list of 20 citys , states table permtable: city , state //- has hundreds of citys , states

i want 2 things:

i want utilize city , state temptable , query permtable see if contains city , state. if doesn't want add together it.

if has match in city , state, want play c:\sound.wav , want add together

permtable.

i lost how this.

this tell records exist or don't exist temptable:

select t.city, t.state, case when p.state null 'does not exist' else 'does exist' end temptable t left bring together permtable p on t.city = p.city , t.state = p.state

you can insert records don't exists in permtable such:

insert permtable select t.city, t.state temptable t left bring together permtable p on t.city = p.city , t.state = p.state p.state null

not sure requirement play sound , doesn't create sense add together (since exists).

mysql

No comments:

Post a Comment