473,385 Members | 1,445 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,385 software developers and data experts.

SQL Select - How do I do this?

Hello

I'm having difficulty writing an SQL command required for my web
application.

I have two tables: WebItems and Costumes. WebItems contains each
instance of a fancy dress costume in my database. Costumes contains all
the general information on each costume.

I want to select all the WebItem records and link them to Costumes to
get further details.

WebItem has four fields: Id (primary key), CodeNumber, webcat_id (the
category the item is in) and sequence.

Costumes has lots of fields, including code (which links to
WebItem.CodeNumber) and Photo, which contains a file name for the
product image.

I basically need to get back only one row per unique Costumes.Photo.

For example, Costumes contains...

Name Photo
----------------------------------------------------------------
Robin Hood /images/robin.jpg
Robin Hood (L) /images/robin.jpg

I only want to display one option per photograph - how to I restrict my
select statement to achieve this?

I've tried linking the tables together and then using a GROUP BY on
Costumes.Photo:

SELECT Costumes.Photo
FROM Costumes RIGHT JOIN WebItem ON Costumes.Code = WebItem.codenumber
WHERE (((WebItem.webcat_id)=55) AND ((Costumes.Photo)<>""))
GROUP BY COstumes.Photo

But this method doesn't allow me to get any other required data, only
Costumes.Photo.

Any help will be greatly appreciated.

James Bird

May 22 '06 #1
1 1108
>I've tried linking the tables together and then using a GROUP BY on
Costumes.Photo:

SELECT Costumes.Photo
FROM Costumes RIGHT JOIN WebItem ON Costumes.Code = WebItem.codenumber
WHERE (((WebItem.webcat_id)=55) AND ((Costumes.Photo)<>""))
GROUP BY COstumes.Photo

But this method doesn't allow me to get any other required data, only
Costumes.Photo.


Try using the First() function with other columns, as in

SELECT First(Costumes.whatever), Costumes.Photo ...
.... GROUP BY Costumes.Photo

May 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: John Fabiani | last post by:
Hi, I'm a newbie and I'm attempting to learn howto create a select statement. When I use >>> string1='18 Tadlock Place' >>> cursor.execute("SELECT * FROM mytest where address = %s",string1) All...
0
by: dregier | last post by:
attached is my full query that I am currently working on: Declare @counterday1 int Declare @counterday2 int set @counterday1 = '20' set @counterday2 = '629' Declare @CounterMin07_01 float...
1
by: joealonso | last post by:
Problem: I have an xml news feed: blah blah yesterday by the news from General Motors (NYSE:GM) that helped bring the market to a three-week high blah blah We all know that the old days are...
4
by: celerystick | last post by:
This is an xsl question, comp.infosystems.www.authoring.stylesheets were not able to help , here goes .... With one xml file containing repeated element <subject>: ...
1
by: palmiere | last post by:
Im trying to do the following: I have 2 select boxes, both are pre populated with data. The first box is a single select box, the 2nd is a multiple select box. Depending on the 1st selection, I...
6
by: Steve Lefevre | last post by:
Hey folks -- I have a series of selectboxes on a web form. I would like to have a javascript jump the focus to the next selectbox when the user presses a key. Each box has the values 1 through...
1
by: serena.delossantos | last post by:
Trying to insert into a history table. Some columns will come from parameters sent to the store procedure. Other columns will be filled with a separate select statement. I've tried storing the...
2
by: naima.mans | last post by:
Hello, i want to select 2 following brothers nodes wich are one under another (one closed to another)... i have done one xslt file... but it's not really good.. for example: the xml file:...
2
by: artev | last post by:
if I insert a string null in a select, it change position; why? I insert value "" in 2nd 3th select; <style type="text/css"> td {border:2px solid pink;}; </style>
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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 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.