Use laravel to generate an SQL statement with parentheses.
Laravel query builder use where case I want to SQL like that:
select * from `wxm_ticket` where `wxm_ticket`.`deleted_at` is null and `user_id` = ? and `sell_status` = ? and (`stop_sell` is null or `stop_sell` >= ?)
Php code:
$query = TicketModel::user($admin_id)->sellStatus(1)->where(function($query){$query->orWhereNull('stop_sell')->orWhere('stop_sell', '>=', \Carbon\Carbon::now());});;
The SQL statement field name is in English and contains English brackets. What is the query error?
Select [COD (mg/L)] from huaxue
Try
Create user level and other automatic brackets in SQL2000
User and level are considered by sqlserver as keywords reserved by the system. Using them directly may cause ambiguity in some places. Adding brackets does not affect any use. However, brackets should also be added in the statement. In the code, the field name is not in brackets. Brackets should also be added to standard SQL statements. For example:
SELECT [F1], [F2], [F3] FROM [MyTable] WHERE [F1] = @ f1 AND [F2] = @ f2
In C # code, such as DataTable and DataReader, brackets are not required when you need to use the field name or table name.
For example, a DataTable tb;
Tb. Rows [0] ["F1"], instead of tb. Rows [0] ["[F1]"]