Skip to main content

I have a two tables oc_order and oc_customer. I want to get customers who order more than once.

This is sample:

oc_order:

order_id | cus_id | cus_name
-------------------------------
1        | 1      | Kumar
2        | 2      | Vimal
3        | 1      | Kumar
4        | 3      | Ramesh

oc_customer

  cus_id   | cus_name |  cus_address
    -----------------------------------
    1        | Kumar    |  Chennai
    2        | Vimal    |  Coimbatore
    3        | Ramesh   |  Selam
    4        | Deepan   |  Chennai
    5        | Ashok    |  Coimbatore

For the above example i want to select only repeated order customer details only.

I mean now select only cus_id- 1 details, because customer one order more then one time.

This is the query am used

SELECT *  
FROM oc_order o  
LEFT JOIN oc_customer oc ON (o.customer_id = oc.customer_id)  
WHERE  (SELECT * 
        FROM oc_order 
        WHERE customer_id=o.customer_id)

I have a two tables oc_order and oc_customer. I want to get customers who order more than once.

This is sample:

oc_order:

order_id | cus_id | cus_name
-------------------------------
1        | 1      | Kumar
2        | 2      | Vimal
3        | 1      | Kumar
4        | 3      | Ramesh

oc_customer

  cus_id   | cus_name |  cus_address
    -----------------------------------
    1        | Kumar    |  Chennai
    2        | Vimal    |  Coimbatore
    3        | Ramesh   |  Selam
    4        | Deepan   |  Chennai
    5        | Ashok    |  Coimbatore

For the above example i want to select only repeated order customer details only.

I mean now select only cus_id- 1 details, because customer one order more then one time.

This is the query am used

SELECT * FROM oc_order o LEFT JOIN oc_customer oc ON (o.customer_id = oc.customer_id) WHERE  (SELECT * FROM oc_order WHERE customer_id=o.customer_id)

I have a two tables oc_order and oc_customer. I want to get customers who order more than once.

This is sample:

oc_order:

order_id | cus_id | cus_name
-------------------------------
1        | 1      | Kumar
2        | 2      | Vimal
3        | 1      | Kumar
4        | 3      | Ramesh

oc_customer

  cus_id   | cus_name |  cus_address
    -----------------------------------
    1        | Kumar    |  Chennai
    2        | Vimal    |  Coimbatore
    3        | Ramesh   |  Selam
    4        | Deepan   |  Chennai
    5        | Ashok    |  Coimbatore

For the above example i want to select only repeated order customer details only.

I mean now select only cus_id- 1 details, because customer one order more then one time.

This is the query am used

SELECT *  
FROM oc_order o  
LEFT JOIN oc_customer oc ON (o.customer_id = oc.customer_id)  
WHERE  (SELECT * 
        FROM oc_order 
        WHERE customer_id=o.customer_id)
Source Link

Mysql query for get repeated customers list

I have a two tables oc_order and oc_customer. I want to get customers who order more than once.

This is sample:

oc_order:

order_id | cus_id | cus_name
-------------------------------
1        | 1      | Kumar
2        | 2      | Vimal
3        | 1      | Kumar
4        | 3      | Ramesh

oc_customer

  cus_id   | cus_name |  cus_address
    -----------------------------------
    1        | Kumar    |  Chennai
    2        | Vimal    |  Coimbatore
    3        | Ramesh   |  Selam
    4        | Deepan   |  Chennai
    5        | Ashok    |  Coimbatore

For the above example i want to select only repeated order customer details only.

I mean now select only cus_id- 1 details, because customer one order more then one time.

This is the query am used

SELECT * FROM oc_order o LEFT JOIN oc_customer oc ON (o.customer_id = oc.customer_id) WHERE  (SELECT * FROM oc_order WHERE customer_id=o.customer_id)