Hi,
Hopefully someone can help.
I am trying to establish (using a straight MySQL query in version 4.0.18)
the level of qualifications someone has, i.e. degree, postgraduate degree or
other.
To simplify things, I need to use only two tables, namely:
master table, containing:
staffno (Primary Key);
forename;
surname;
psnquals table, containing:
psnqualid (Primary Key);
staffno (Foreign Key);
levelid (where 1 = degree, 2 = postgraduate degree, 3 = other)
In the followning query, staffno 1 has three qualification levels, 1, 2, 3.
The query finds the first matching record (where cdelevelid = 1) and then
stops, making it appear as if the employee had no postgraduate
qualification.
One person can have one or all of the above qualifications. I need to write
a query that shows if a person has one, two or all of the above. I tried
using the following query, but it seems only to look at the first psnqualid
record it finds and then stops:
SELECT m1.staffno, m1.forename, m1.surname,
CASE WHEN p1.cdelevelid = 1 THEN "D" WHEN p1.cdelevelid = 2 THEN "P" ELSE
"O"
FROM `master` m1
INNER JOIN psnquals p1 ON m1.staffno = p1.staffno
I also tried using an IF statement, but this also seemed to stop after
finding the first matching record in the psnquals table.
Any suggestions wouls be most welcome.
Thanks,
Mark H
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.684 / Virus Database: 446 - Release Date: 13/05/2004 2 1248
Mark Hargreaves wrote: Hi,
Hopefully someone can help.
I am trying to establish (using a straight MySQL query in version 4.0.18) the level of qualifications someone has, i.e. degree, postgraduate degree or other.
To simplify things, I need to use only two tables, namely:
master table, containing: staffno (Primary Key); forename; surname;
psnquals table, containing: psnqualid (Primary Key); staffno (Foreign Key); levelid (where 1 = degree, 2 = postgraduate degree, 3 = other)
In the followning query, staffno 1 has three qualification levels, 1, 2, 3. The query finds the first matching record (where cdelevelid = 1) and then stops, making it appear as if the employee had no postgraduate qualification.
One person can have one or all of the above qualifications. I need to write a query that shows if a person has one, two or all of the above. I tried using the following query, but it seems only to look at the first psnqualid record it finds and then stops:
SELECT m1.staffno, m1.forename, m1.surname, CASE WHEN p1.cdelevelid = 1 THEN "D" WHEN p1.cdelevelid = 2 THEN "P" ELSE "O" FROM `master` m1 INNER JOIN psnquals p1 ON m1.staffno = p1.staffno
I also tried using an IF statement, but this also seemed to stop after finding the first matching record in the psnquals table.
Any suggestions wouls be most welcome.
Thanks,
Mark H
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 13/05/2004
SELECT staffno, forename, surname, cdelevelid
FROM master
and do the conversion from numeric to alpha levels in the program that
invokes the query.
HTH
jerry gitomer wrote: Mark Hargreaves wrote:
Hi,
Hopefully someone can help.
I am trying to establish (using a straight MySQL query in version 4.0.18) the level of qualifications someone has, i.e. degree, postgraduate degree or other.
To simplify things, I need to use only two tables, namely:
master table, containing: staffno (Primary Key); forename; surname;
psnquals table, containing: psnqualid (Primary Key); staffno (Foreign Key); levelid (where 1 = degree, 2 = postgraduate degree, 3 = other)
In the followning query, staffno 1 has three qualification levels, 1, 2, 3. The query finds the first matching record (where cdelevelid = 1) and then stops, making it appear as if the employee had no postgraduate qualification.
One person can have one or all of the above qualifications. I need to write a query that shows if a person has one, two or all of the above. I tried using the following query, but it seems only to look at the first psnqualid record it finds and then stops:
SELECT m1.staffno, m1.forename, m1.surname, CASE WHEN p1.cdelevelid = 1 THEN "D" WHEN p1.cdelevelid = 2 THEN "P" ELSE "O" FROM `master` m1 INNER JOIN psnquals p1 ON m1.staffno = p1.staffno
I also tried using an IF statement, but this also seemed to stop after finding the first matching record in the psnquals table.
Any suggestions wouls be most welcome.
Thanks,
Mark H
--- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.684 / Virus Database: 446 - Release Date: 13/05/2004
SELECT staffno, forename, surname, cdelevelid FROM master
and do the conversion from numeric to alpha levels in the program that invokes the query.
HTH
Or add a third table level (id INT PRIMARY KEY, code CHAR) with VALUES
(1, "D"), (1, "P", (3, "O"). It's probably better to do lookup with a
table rather than with code. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike |
last post by:
I want to be able access an xml file using an XPath? query to go to a
specific node. Once I have that node I want to be able to retrieve the value
of an attribute. Can't seem to get this working using the 2.0 Framework.
Here's a sample of the XML
<Agency>
<vu_Agency AgencySysNo="1" Name="Dept 1"/>
<vu_Agency AgencySysNo="2" Name="Dept 2"/>
|
by: Wojciech Wendrychowicz |
last post by:
Hello to All,
I'm trying to retrieve records from AS/400 in an VBA application.
So, I've made an RPG program, then a stored procedure wchich calls that RPG
program, and finally some VBA code to call the stored procedure and retrieve
data from AS/400.
The problem is, that when I finally run my VB code, it just hangs.
But when I call the same stored procedure from "pure" SQL - it works
perfect. (I evaluate Aqua Data Studio 3.7)
What I...
|
by: Andy |
last post by:
Hi All.
I'm working for a company that has set out a guideline for retrieving
data from a database. Nobody can explain to me the reason for the
following.
When retrieving a set of records from database to a VB.net app, they
retrieve the database fields as a record set
eg. "select name, suburb from myTable"
|
by: Nemisis |
last post by:
Hi everyone, sorry if this post gets really long, i just wanna make
sure i fully explain what i am trying to do. I am new to OOP and .net
2.0, so if this is obvious, i am sorry.
I have wrote a data access layer, which contists of separate
servicebases for each object within my database.
CompanyDataService (contains CRUD methods)
ContactDataService (contains CRUD methods)
|
by: Randy Smith |
last post by:
Hi ALL,
I wonder if anyone has been using n-tier to bind to a GridView control by
using the ObjectDataSource. This is our first OOP web application, and we
have no tables. Right now we are simply working with objects in memory.
So, it appears as though Microsoft requires that our datamapper classes
reside inside a folder called "App_Code", and NO WHERE ELSE.
So, has anyone successfully been able to place their datamappers in a...
| |
by: Sanjay Pais |
last post by:
I have a table with over 1.3 million rows. I am retrieving only 20 at a time
using the with - over clauses
In query analyser, the data is retrieved in under a second.
When retrieving using the data adaptor.fill or datareader to retrieve the
data it takes over 24 seconds.
public System.Data.SqlClient.SqlDataReader List1(int PageIndex, int
PageSize, string ItemName, string UserIDs, DateTime DateStart, DateTime
DateEnd, int status,...
|
by: Chris L. |
last post by:
Hi, I'm trying to set up a generic mechanism that would allow the
following:
1: Run <this_procedure>
2: After that, run <this_review_procedure>
3: If it returns non-zero, open <this_form>
The idea is that the first procedure would have to update records.
After that, the review procedure would check if there are unupdated
records. If there are, a form would open to show the problem records,
|
by: gophersounds |
last post by:
When I run this simple program I am not getting any data back. The program creates a database, creates a table, populates the table with some data, and then tries to read the data. However, no records are returned in the ResultSet. I verify through MySQL Query Browser that the database is created and populated. I've also been unable to retrieve records with other databases. Because I'm creating the database at the root I don't think admin...
|
by: ADezii |
last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows() Method of the Recordset Object. This Method varies slightly from DAO to ADO, so for purposes of this discussion, we'll be talking about DAO Recordsets. The ADO approach will be addressed in the following Tip. We'll be using a Query, consisting of 5...
|
by: ADezii |
last post by:
Last Tip, we demonstrated the technique for retrieving data from a DAO Recordset, and placing it into a 2-dimensional Array using the GetRows() Method. This week, we will cover the same exact Method (GetRows()), but only as it applies to an ADO Recordset. Although there are similarities in the 2 methodologies, the ADO Method offers 2 more Optional Arguments, is a little more complex, and of course, the syntax is different in creating the...
|
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: 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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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: 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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |