Jump to content

difficult(for me) query help


dadamssg87

Recommended Posts

I have a table products: id, username, code, price, description, and iteration. The "code" column is an alphanumeric string unique to that product. Instead of having a form to update that row, i was thinking i could add an "iteration" column and create a whole new row with the updated information. This  way i could track how the product changes and progresses over time. The "iteration" would be an integer and increase +1 every time that product gets updated.

 

Could someone help me write a query that selects the latest iteration of all products with a certain username? I have no idea how to incorporate the code and iteration together.

 

Any help would be MUCH appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/252638-difficultfor-me-query-help/
Share on other sites

Products

IdUsernamecodepriceiteration

 

14xyz1.990

 

24xyz4.991

 

34xyz2.992

 

47asgprice0

 

56ewrprice0

 

64123price0

 

SELECT id, username, code, price, iteration
FROM Products
where iteration = ( SELECT MAX(iteration) FROM table WHERE username = Products.username )

 

The above code would produce the following? I'm not sure what the "t" represents in your query and also don't see how your query gets the max() iteration of each product code.

 

 

IdUsernamecodepriceiteration

34xyz2.992

64123price0

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.