简体   繁体   中英

How to compare the one table elements to another table

Using below query I am getting the last record which is updated in the table using update_date

SELECT form_id,form_elements,form_builder_type, update_date FROM `form_builder` WHERE form_id=1 AND form_builder_type='example' ORDER BY update_date DESC LIMIT 1

Output is below

在此处输入图片说明

Now I have the second table with field name and field type

在此处输入图片说明

I have to check the form_elements which are coming from the first table is available or not in the second table. If available in the table then display the field name and field type

I need an output like

lastname:  text
email   :  email

Would you help me out in this?

will not tell you that saving data like you do is not correct way to do things, so:

SELECT t.id, t.form_builder_type, e.field_type FROM form_builder t
LEFT JOIN form_elements e 

ON e.field_name regexp concat('(',replace(e.form_elements, ',','|'),')');

Hope you'll use it to update your scheme ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM