I'm stuck on a host that is still running MYSQL version 3.
I need to flatten out a relationship to AND a set of criteria.
In a nutshell
User
UserID
UserEmail
UserOther
UserSkills
UserID
SkillCode
Any user may have zero, one, or many UserSkills.
I need to find a list of UserIDs for Users who have SkillCodes A and SkillCode
B.
How do I write the query (queries)?
Jul 17 '05
11 2315
Lemming wrote: On Thu, 14 Oct 2004 14:49:03 +1300, Chris Hope <bl*******@elec trictoolbox.com > wrote:
[Aargh! The amended fu got me. Reposting]
Gene Wirchenko wrote:
This gets much messier when the number of skill codes is variable - you probably end up having PHP construct a query in a loop.
select userid from userskills group by userid where skillcode in ('A','B','C','D ') having count(*)=4
Nice solution :)
Minor syntax quibble: does MySQL allow "where" after "group by"?
Looks like he got the query in the wrong order, because you are correct,
group by must be after the where clause. Therefore his query should be:
select userid from userskills
where skillcode in ('A','B','C','D ')
group by userid
having count(*)=4
--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
On Fri, 15 Oct 2004 14:07:51 +1300, Chris Hope
<bl*******@elec trictoolbox.com > wrote: Looks like ...
[snip]
You keep changing the followup-to line and removing most of the
groups. Please don't do that. I don't read comp.lang.php, so if I
was to not change followup-to back to include the full list of groups
I would be posting to groups I don't read, so wouldn't see either my
own post nor any replies.
Lemming
--
Curiosity *may* have killed Schrodinger's cat. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Theodor Ramisch |
last post by:
Hi there,
I've got a simple table with an ID and a parentID field which build the relation
between the entries. Now I want to select some entries and count their childs.
This is what I tried:
SELECT NAME, ID, parentID,
(SELECT COUNT(ID) FROM myTable WHERE parentID=???ID???)
AS CHILDS FROM myTable WHERE parentID=0 ORDER BY parentID ASC
|
by: David |
last post by:
Consider this SQL Query:
-----------------------------------------------------------------
SELECT c.CASE_NBR, DATEDIFF(d, c.CREATE_DT, GETDATE()) AS Age,
c.AFFD_RCVD, c.PRV_CRD_ISS, x.RegE, x.Type, x.Fraud,
c.CUST_FN + ' ' + c.CUST_LN AS CustFullName,
c.ATM_CKCD_NBR, x.TotalLoss, x.Queue, x.Status,
c.QUEUE AS Expr1, x.CHECK_ACT_NBR, c.CUST_LN, c.SSN,
c.CREATE_DT
FROM (
SELECT TOP 9999999 cl.CASE_NBR, cl.SSN, cl.CREATE_DT,
|
by: Wanny |
last post by:
Hi There,
I can't seem to see what's wrong with the query below
DELETE
FROM Users_Details UD1
WHERE UD1.UserID = (
SELECT TOP 1 UD2.UserID
FROM Users_Details UD2
WHERE UD1.useremail = UD2.useremail
|
by: krystoffff |
last post by:
Hi
I would like to paginate the results of a query on several pages. So I
use a query with a limit X offset Y to display X results on a page,
ok.
But for the first page, I need to run the same query with a count(*)
to know how many pages I will get (number total of rows/ X).
The problem is my query is very slow (maybe 5s) because there is much
|
by: Todd |
last post by:
Data related to the query I'm working on is structured such that
TableA and TableB are 1-many(optional). If an item on TableA has
children on TableB, I need to use the Max(tstamp) from Table B in a
condition, otherwise I need to use a tstamp from TableA (note:there
are additional tables and conditions for this query, but this problem
is based around these 2). I attempted having TableB (as B) "left
outer joined" to TableA, and a condition...
| |
by: Patrick Fisher |
last post by:
Hi
I have a table which Contains entries with RefCode field containing
INVP or INVPD
Common fields in each entry would be InvoiceNo, Total and PurTyp for
example.
You could have 1001 500.50 INVP 1
1001 500.50 INVPID 1
1002 123.00 INVP 1
|
by: ungahz |
last post by:
hi all. im having a problem and wondering if anyone an help. i have the
following tables along with column names (too many columns so im just
including the relevent ones):
folders
---------
name
id
categoryid
|
by: Richard |
last post by:
In a manufacturing document control situation, a procedure revision
table named has principal columns and
and satellite data columns , , . A
unique index and to ensure each procedure name has
only unique revision numbers.
A form has a listbox for selecting a procedure and revision for
browsing, and a checkbox 'Show all'.
When ShowAll is true the listbox rowsource can be .
When ShowAll is false the listbox should only show each...
|
by: eltontodd |
last post by:
I have a query that I need to run on a database that is on a SQL Server 7 installation. When I run the query on that database it takes forever. If I take the same query and run it on a database that is on a SQL Server 2000 installation it runs under a minute. I was wondering if someone might be able to help me redefine the query so that it works faster under SQL Server 7 but still returns the same results. The query is:
Select DISTINCT...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |