Hi,
I am converting some queries from stored procedures in MS Access to MySQL,
and have hit my first problem. The Access query references another stored
procedure, which is where the problem lies.
I have the following table data: (apologies if the columns aren't aligned
properly... it looks ok in a fixed-width font)
img_num img_page img_sect img_order
1 1 1 3
2 1 1 1
3 1 1 2
4 1 2 1
5 1 2 3
6 1 2 2
7 1 3 2
8 1 3 3
9 1 3 1
10 2 1 2
11 2 1 1
12 2 2 1
13 2 2 2
14 3 1 1
15 3 2 1
This relates to a numbered list of image files from 1 to 15. These images
are distributed throughout 3 different pages: 1, 2 and 3. On each of these
pages are separate sections. Each section has images belonging to it. So, as
you can see, on page 1, there are 3 numbered sections, each of which 'owns'
3 images.
What I am attempting to do is design a query that returns all of a given
image's 'siblings', which are then ordered by a column. So, for example, if
I were attempting to query for all the siblings of image number 1, the query
would return:
img_num
2
3
1
Or if I were to query for all the siblings of image number 10, the query
would return:
img_num
11
10
Or, for image number 6:
img_num
4
6
5
I wrote this query in MS Access using stored procedures and it worked
beautifully. But now I'm moving to MySQL that option isn't available to me
(I'm using v.4) and I just can't figure it out. I've tried joins and
subqueries, but I just cannot get my head around it. But I'm not the most
knowledgeable when it comes to database queries!
This is a simplified scenario, as the query needs to return several columns,
but I'm sure I've given all the info needed.
Hoping someone can help...
Plankmeister 2 1829
The Plankmeister wrote: What I am attempting to do is design a query that returns all of a given image's 'siblings', which are then ordered by a column.
So siblings are defined by a matching img_page and img_sect?
SELECT Sibling.*
FROM MyImageTable AS Given INNER JOIN MyImageTable AS Sibling
ON Given.img_page = Sibling.img_page
AND Given.img_sect = Sibling.img_sect
WHERE Given.img_num = ?
ORDER BY Sibling.img_order
Substitute the img_num of your given image for the "?" and you're set.
Regards,
Bill K.
Bill.... You are a star. : )
"Bill Karwin" <bi**@karwin.com> wrote in message
news:ck*********@enews1.newsguy.com... The Plankmeister wrote: What I am attempting to do is design a query that returns all of a given image's 'siblings', which are then ordered by a column.
So siblings are defined by a matching img_page and img_sect?
SELECT Sibling.* FROM MyImageTable AS Given INNER JOIN MyImageTable AS Sibling ON Given.img_page = Sibling.img_page AND Given.img_sect = Sibling.img_sect WHERE Given.img_num = ? ORDER BY Sibling.img_order
Substitute the img_num of your given image for the "?" and you're set.
Regards, Bill K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Mahesh Hardikar |
last post by:
Hi ,
Oracle 8.1.7.0.0 on HP-UX 11.0
I am a newbie as far as PL-SQL is concerned . I have Sybase/MSSQL
T-SQL background.
We have a report which uses a select statement . This select...
|
by: Laphan |
last post by:
Hi All
Sorry for the spare info. It wasn't because I didn't want to display it. I
just didn't know how to get the data that you needed. I think I've got it
now so please note the following:
...
|
by: sal cifone |
last post by:
Hello,
I am trying to use access vba instead of running an unmatched query.
I want to compare two tables and if there is a new sales office in
"Commissions" table that is not in the "Conversion"...
|
by: Lumpierbritches |
last post by:
I have a query that pulls information for a report. Sometimes the report is in
tact and works wonderful; other times the report gives me a syntax error. The
information is only different in one...
|
by: Riley DeWiley |
last post by:
I have an UPDATE query that is always setting 0 records. When I cut and
paste the SQL into Access and use it, it fails in the same way unless I
coerce the date fields to be '=now()', in which case...
|
by: s_wadhwa |
last post by:
SELECT DISTINCTROW "01C" AS dummy, Buildings.BuildingNumber,
UCASE(Buildings.BuildingName) AS BuildingName,
Buildings.MasterPlanCode, Buildings.UniformBuildingCode,...
|
by: Reedsp |
last post by:
OS: MS XP
Access version: 2003 SP2
I am trying to use an update query to replace quote marks with nothing. In essence, I'm removing quote marks. I get a error message when a field is empty or...
|
by: shilpasharma |
last post by:
Hi,
Can anybody let me know how I can optimise following Query.
Select * from reports
where
( exists ( SELECT 1 FROM results_required rr, item_claims_trials ict, results res
WHERE...
|
by: bruce.dodds |
last post by:
Access seems to be handling a date string conversion inconsistently in
an append query.
The query converts a YYYYMM string into a date, using the following
function:
CDate(Right(,2) & "/1/" &...
|
by: John1975 |
last post by:
OS: XP
MS Access 2007
Having some trouble with a join.
I have three tables: progress_reports, clippership_archives, and employee conversion
progress_reports:
id
emp_id
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
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: 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...
|
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...
| |