Generation

text to sql syntaxSun, 25 Jun 2023

主从表,主表的日期在某个范围内的数据,子表会有多条数据,子表只要符合某个条件的一条数据,主表就记1

SELECT * FROM `order` where ctime between '2017-03-01' and '2017-05-22' and id in (select order_id from order_detail where status = 1 )

Questions about programming?Chat with your personal AI assistant