Solved

combine two queries

Posted on 2011-03-04
4
236 Views
Last Modified: 2012-05-11
I have to combine php and sql.  I want to have one sql statement

this is a for loop that checks to see if $productid is in addonitems

select productid from addonitems where productid=$productid



update orderitems set addon=1 where productid=$productid
0
Comment
Question by:rgb192
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
derekkromm earned 250 total points
ID: 35037231
update orderitems set addon=1 where productid=$productid and exists (select 1 from addonitems where productid = $productid)
0
 
LVL 18

Expert Comment

by:sventhan
ID: 35037251
update t
set addon = 1
from orderitems t
where productid=$productid
0
 
LVL 18

Assisted Solution

by:sventhan
sventhan earned 250 total points
ID: 35037356
added the exists

update t
set addon = 1
from orderitems t
where productid=$productid
and exists (select 1 from addonitems where productid = $productid)
0
 

Author Closing Comment

by:rgb192
ID: 35038174
thanks
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now