<span>select</span> <span>*</span> <span>from</span> `wxm_ticket` <span>where</span> `wxm_ticket`.`deleted_at` <span>is</span> <span>null</span> <span>and</span> `<span>user_id</span>` <span>=</span> ? <span>and</span> `sell_status` <span>=</span> ? <span>and</span> (`stop_sell` <span>is</span> <span>null</span> <span>or</span> `stop_sell` <span>>=</span> ?)
php code:
<span>$query</span> = TicketModel::user(<span>$admin_id</span>)->sellStatus(1)->where(<span>function</span>(<span>$query</span><span>){ </span><span>$query</span>->orWhereNull('stop_sell')->orWhere('stop_sell', '>=', \Carbon\Carbon::<span>now()); });;</span>
select [COD(mg/L)] from huaxue
试试
user, level 被sqlserver认为是系统保留关键字,直接使用有可能在某些地方造成歧义。加上了中括号,不影响任何使用,但是在语句里,也应当加上括号,在代码里面,字段名是没有括号的。标准SQL语句也应当加上括号。比如:
SELECT [F1], [F2], [F3] FROM [MyTable] WHERE [F1] = @f1 AND [F2] = @f2
在C#代码里,比如DataTable,DataReader里面,需要使用字段名或者表名的时候,不需要使用括号。
比如一个DataTable tb;
tb.Rows[0][ "F1" ] 就可以了,而不需要 tb.Rows[0][ "[F1]" ]