sql - knowing if new record already exists -


i'm trying check if record i'm insert on table exists must check 2 fields against array...

i have table user , year, this

john, 2002 john, 2003 john, 2004 

and insert statement

foreach ($years $value) { $queryinsert = "insert  payments values ('$var1','$value')"; 

but variable $years have values(1999,2000,2001,2002,2003)

how can make check before insert values on db if have user year , report in msg user john paid year 2002, 2003!

try one:

$queryinsert = "insert payments (name,year) select * (select '$var1','$value') tmp not exists (     select name, year payments name = '$var1' , value='$value' ) limit 1;" 

i assume names of columns name , year. should change them are.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -