Jump to content

Need help in using LIKE


newphpcoder

Recommended Posts

Hi..

 

 

I have 2 tables with Cloth column.

 

sales_order table

Cloth -column

 

sample data of  Cloth

 

3392

3520

3392 Yellow/White

3392 BLUE

3392 RED

3392 Orange

 

cloth_parameter - table

Cloth -column

 

sample Cloth

3392N

3520

3392Yellow/White

3392 Blue

3392 Red

3392Orange

 

How can I equal the two data eventhough the format of data has difference using like.

 

Thank you

 

 

Link to comment
Share on other sites

This was the closest I have so far

sales_order
+-----+-------------------+
| sid | cloth             |
+-----+-------------------+
|   1 | 3392              |
|   2 | 3520              |
|   3 | 3392 Yellow/White |
|   4 | 3392 BLUE         |
|   5 | 3392 RED          |
|   6 | 3392 Orange       |
+-----+-------------------+

cloth_parameter
+-----+------------------+
| cid | cloth            |
+-----+------------------+
|   1 | 3392N            |
|   2 | 3520             |
|   3 | 3392Yellow/White |
|   4 | 3392 Blue        |
|   5 | 3392 Red         |
|   6 | 3392Orange       |
+-----+------------------+


SELECT s.sid, s.cloth as cloth_s, c.cid, c.cloth as cloth_c
FROM sales_order s
INNER JOIN cloth_parameter c
    ON REPLACE(s.cloth, ' ', '') = REPLACE(c.cloth, ' ', '')


Result-->
+-----+-------------------+-----+------------------+
| sid | cloth_s           | cid | cloth_c          |
+-----+-------------------+-----+------------------+
|   2 | 3520              |   2 | 3520             |
|   3 | 3392 Yellow/White |   3 | 3392Yellow/White |
|   4 | 3392 BLUE         |   4 | 3392 Blue        |
|   5 | 3392 RED          |   5 | 3392 Red         |
|   6 | 3392 Orange       |   6 | 3392Orange       |
+-----+-------------------+-----+------------------+

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.