SELECT a.*, r.id AS rid, r.`name` AS rname, r.nameZh AS rnameZh FROM t_admin a LEFT JOIN t_admin_role ar ON a.id = ar.adminId LEFT JOIN t_role r ON r.id = ar.rid WHERE a.id != 1 AND a.`name` LIKE ( "%", "华", "%" ) ORDER BY a.id
时间: 2024-04-14 18:28:33 浏览: 122
The error in your SQL query lies in the WHERE clause. The LIKE operator requires a single column or expression as the second operand, but you are providing multiple values enclosed in parentheses.
To fix this issue, you need to modify the LIKE condition. If you want to search for records where the name column contains the string "华", you can use the following syntax:
```sql
SELECT
a.*,
r.id AS rid,
r.`name` AS rname,
r.nameZh AS rnameZh
FROM
t_admin a
LEFT JOIN t_admin_role ar ON a.id = ar.adminId
LEFT JOIN t_role r ON r.id = ar.rid
WHERE
a.id != 1
AND a.`name` LIKE '%华%'
ORDER BY
a.id;
```
This updated query will search for records in the `t_admin` table where the `name` column contains the substring "华". The `%` symbols are used as wildcards to match any characters before or after "华".
Please note that this query assumes you have properly defined and related tables `t_admin`, `t_admin_role`, and `t_role` in your database. Adjust the table names and join conditions accordingly based on your actual database schema.
阅读全文