Jump to content

2 tables Query Help


fabiangarga

Recommended Posts

Hi guys, im new on this forum.

I have a little problem with a SQL query, im trying to get a query feedback but im lost.

I got 2 tables

Table 1:
ID_product ,  price

Then have a second table

Table 2:
ID, Description

On the second table, the column description contains a string, and somewhere in the string it has this text "{price = A}", the price is the same from the table 1.
What im trying to figure out, is how i can display ID_product, price,from table 1, and also the ID from the row that contains the same price as the table 1 in the string.
Im not sure if im clear, im not really good writing and less in english.

I will apreciate the help, thanks!

Link to comment
Share on other sites

Does that "=A" mean anything? Is it more than just inserting the price in at the "{price}"?

 

How do you relate the two tables? Does table 2's ID pair with table 1's ID_product? Any reason why the description is in its own separate table when they sound like they match up with individual products?

Link to comment
Share on other sites

Im working with a joomla data base, one table is from a e-commerce plugin and the other is from the article description wich contains in some part the price of the product.
I dont need to insert, i need to select and get a feedback with the id_product, ID of the article wich contains the price of the product on the description and the price.
The price, and id of the product i can get it easly from the table of the e-commerce plugin, but i need to get on the same feedback the ID of the article wich contains the price.

This is an example of the 2 tables

uQ6Efl8.jpg

 

The feed will be something like this:

 

3jzDvqR.jpg

Link to comment
Share on other sites

My bad, in the description also i have somewhere in the test a string with {id="product_id"} and this one is unique, what could happen is that one article on the description has more than one product_id, but i think it will not screw my future php code.

I cant alter the table, because it will mess up the e-commerce, i dont know if this could be done with mysql, probably yes, but it will require a lvl of mysql that i dont have, i was thinking solve it using php and , like having 2 multi arrays with each tables, and then with php, serch into the second table and make a third array with the data i need.
If i could make it in one sql query it will be fantastic.

Link to comment
Share on other sites

I asked to a person that knows a lot more than me and found me a solution to my problem. I dont know how big is this forum comunity, or if mysql is not the most popular topic, but thanks to requinix for the answers.

 

The query was solved using CONCAT 

 

 



SELECT
pc.id, p.product_id, p.price, pc.Description
FROM table1 p, table2 pc
WHERE pc.Description like concat('%price=', p.product_id, '%')


 

 

Hope that someone found this answer useful

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.