0

表名:customer_datails

customer_id           customer_name
101                    Hari prasad
102                    Hari
103                    prasad
104                    Vara Prasad
105                     Sri Hari bandaru
106                    Raja Shekhara Prasad

我有上表。我想显示 CUSTOMER_ID'S WHO ARE HAVING NAME AS 'Hari' 和 'prasad' 。但我需要它与没有和条件的'REGEXP'。我尝试了以下那些正在工作的查询。

例 1)

select cistomer_id from customer_details where customer_name LIKE 'Raja' 'Prasad';

 o/p: 106

例 2)

select cistomer_id from customer_details where customer_name LIKE 'Raja' AND 
           customer_name LIKE 'Prasad';

    O/P: 106.

我需要上面没有“and”条件的正则表达式查询(意味着我不想在像Ex2这样的条件下多次使用customer_name字段)

4

3 回答 3

0

使用以下脚本: select customer_id from customer_details where first_name in ('Raja','Prasad');

于 2013-10-31T16:09:51.803 回答
-1

这应该这样做:

select customer_id from customer_details where customer_name REGEXP '(.*Raja.*)|(.*Prasad.*)';

这可能会帮助你

于 2013-10-31T12:14:49.883 回答
-1

假设您关心订单,以下查询将起作用:

SELECT customer_id
  FROM customer_details
 WHERE customer_name LIKE '%Raja%Prasad%';

如果您以任何顺序需要它们,则必须使用RLIKE

SELECT customer_id
  FROM customer_details
 WHERE customer_name RLIKE 'Raja.*Prasad|Prasad.*Raja';
于 2013-10-30T09:22:46.423 回答