Forum Moderators: coopster

Message Too Old, No Replies

insert into table with condition

insert into table only if date of insert is greater than date joind

         

Mitch888

6:05 am on Mar 18, 2003 (gmt 0)

10+ Year Member



I would like to add a condition in the below table [if date > than $date_join]

$sql="insert into topay_list(user_id, sb_club, each_user_win, wdate, date)
values($i[0], '$i2[0]', $each_user_win, '$date', now())"

how can I re-write the below statement to make it correct?
$sql="insert into topay_list(user_id, sb_club, each_user_win, wdate, date)
values($i[0], '$i2[0]', $each_user_win, '$date', now()) where wdate > '$jdatj'"

thank you

jatar_k

5:07 pm on Mar 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



So you only want to add NOW() if wdate > '$jdatj'? If it isn't greater what do you want to add?

why not do the if in php before you do the insert?

Mitch888

6:14 pm on Mar 18, 2003 (gmt 0)

10+ Year Member



if statements...hmm. i feel stupid :).

you are absolutely right now why couldn'nt I think of that :)

jatar_k

6:18 pm on Mar 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's why we all need an extra pair of eyes sometimes. We get to focused on one aspect of what we are doing and then try it so many times that we need a fresh perspective on what we are trying to do.

That's why we are all here. The power of collective reasoning. :)

Mitch888

7:16 pm on Mar 18, 2003 (gmt 0)

10+ Year Member



Absolutely right