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
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

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.