Newcomer, I would like to ask MySQL for advice on the sql statement for querying after judging and concatenating conditions.
世界只因有你
世界只因有你 2017-05-18 10:45:28
0
1
618

I want to implement the statement that when b.phase>2, execute the splicing condition: AND unix_timestamp()> second_end_time
Otherwise, the splicing condition: AND unix_timestamp()> thirdly_end_time
Can you please tell me how to write this SQL?

SELECT * FROM data a, race b
WHERE
a.race_id = b.race_id
IF (b.phase > 2, AND unix_timestamp()> second_end_time , AND unix_timestamp()> thirdly_end_time)
AND user_id = 123
The above is written randomly by myself, the grammar is not correct, please give me some advice!

世界只因有你
世界只因有你

reply all(1)
伊谢尔伦
SELECT * FROM data a,race b WHERE a.race_id=b.race_id AND ((b.phase>2 AND UNIX_TIMESTAMP()>second_end_time) OR (b.phase<=2 AND UNIX_TIMESTAMP()>thirdly_end_time));
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!