473,387 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Adding two records together.

I am developing a shopping cart and have come across a problem. I have developed it in such a way that there is two carts, I call them the user_cart and the session_cart,, but they all really go to the same place and are only differentiated by the user_id or the cfid columns (one OR the other). I have developed them this way in case one use may have more than one account without cross-breeding information. When the user logs in, any items in his or her cart are added into their user cart. So you see, it is possible to have product # 5 (we'll say) twice.

I would use the GROUP BY command, but if the user deletes that item he or she would have to delete it more than once.

What I need is a way to look at the items the user has in his or her cart, look at the items in the session_cart and if there are any duplicates to add the quantity together.

To see the current status of my cart look at SomeGuysStuff.com

Thank you.
Feb 21 '07 #1
3 2449
Motoma
3,237 Expert 2GB
I am developing a shopping cart and have come across a problem. I have developed it in such a way that there is two carts, I call them the user_cart and the session_cart,, but they all really go to the same place and are only differentiated by the user_id or the cfid columns (one OR the other). I have developed them this way in case one use may have more than one account without cross-breeding information. When the user logs in, any items in his or her cart are added into their user cart. So you see, it is possible to have product # 5 (we'll say) twice.

I would use the GROUP BY command, but if the user deletes that item he or she would have to delete it more than once.

What I need is a way to look at the items the user has in his or her cart, look at the items in the session_cart and if there are any duplicates to add the quantity together.

To see the current status of my cart look at SomeGuysStuff.com

Thank you.
I am not sitting in front of a MySQL database right now, however, depending on the version of MySQL you are using, you might be able to this with a subquery utilizing a union.

Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.     combined.item_id,
  3.     sum(1)
  4. FROM
  5.     (SELECT * FROM cartTable WHERE id = 5
  6.      UNION
  7.      SELECT * FROM cartTable WHERE id = 7) combined
  8. GROUP BY
  9.     combined.item_id
  10.  
Feb 21 '07 #2
That won't work the way I want it to. I need to actually make a change to the db not just display like data together.
Also I need to know how to find the rows that need changing.
Feb 21 '07 #3
Motoma
3,237 Expert 2GB
That won't work the way I want it to. I need to actually make a change to the db not just display like data together.
Also I need to know how to find the rows that need changing.
I know this doesn't really help that much, but you can use LIMIT with UPDATE and DELETE.

Could you try explaining your problem a little differently for me, I'm not sure I am grasping the whole thing.
Feb 21 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Jamie Fryatt | last post by:
Hi everyone, here's what id like to do. I have a table with 2 fields, name and value I need to be able to add multiple records quickly, for example I need to add name value abc 1...
2
by: Dee | last post by:
I have a form which contains basics of a customer's order from table . I placed a tab control on this form which is still empty. I'm trying to design a project management database and would like...
0
by: Tom Esker | last post by:
I have three linked tables that I can update individually but when I put them together into a query, I can no longer update the data. The tables are tied together with a field called "CASEID"...
1
by: RC | last post by:
I have an Access 2002 database with many tables and forms (but just to keep things simple, let's say the DB has one Table "Table1" and one Form "Form1"). I have managed to cobble together so much...
13
by: Shannan Casteel via AccessMonster.com | last post by:
I set up two tables (one with the regular claim info and another with ClaimNumber, PartNumber, and QuantityReplaced). The ClaimNumber is an autonumber and the primary key in both tables. I made a...
4
by: Mike Hnatt | last post by:
My goal is to get data from an XML file into a couple of tables in an Access database. The XML file is a little complex so I need control over what I do (I can't just read it into a dataset). ...
1
by: accessbee | last post by:
(Sorry this is so long, was trying to fully explain the situation) There are two tables that handle information on our clients. Every client has a unique ClientID, and the ClientID is the Primary Key...
4
by: rn5a | last post by:
A MS-Access DB has 3 tables - Teacher, Class & TeacherClass. The Teacher table has 2 columns - TeacherID & TeacherName (TeacherID being the primary key). The Class table too has 2 columns - ClassID...
6
by: santiago | last post by:
I guess one cannot do this: arraytot = arraytot + arraydet; So, what's the trick to adding arrays like this? Thanks.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.