MYSQL query help..... [SOLVED -- myself -- two min later]
Ok, I've got a table like this:
style color size
145 red s
145 red m
145 red l
145 blue s
145 blue m
150 red s
150 red m
etc etc....there is also a sku field as primary key for each item.
I'm sure it's simple, but how the heck can I get a list of style and color without the size?
Like:
style color
145 red
145 blue
150 red
Thanks,
Scott
Edit: answer: select distinct color,style from table;
I thought at first that would only give me the distinct colors for the whole table, not for each style. Ah well
Last edited by firecat53 (2010-02-02 18:06:14)
You can try
select style, color from tablename
where tablename is the name of the table where is your data.
Last edited by noreaga (2010-02-02 18:05:07)
Similar Messages
-
I'm fairly new to DW and MySQL. I'm trying to develop what I
thought was a simple search and results app., but am apparently
having a program logic issue
I have a form with 2 radio buttons, code below:
<form name="card_search" id="card_search" method="post"
action="card_search_results.asp">
<p>
<label>
<input <%If
(CStr((rsCardCatBaseball.Fields.Item("catID").Value)) = CStr("1"))
Then Response.Write("CHECKED") : Response.Write("")%>
type="radio" name="RadioGroupCardCat" value="1" />
Baseball</label>
<br />
<label>
<input <%If
(CStr((rsCardCatBaseball.Fields.Item("catID").Value)) = CStr("2"))
Then Response.Write("CHECKED") : Response.Write("")%>
type="radio" name="RadioGroupCardCat" value="2" />
Football</label>
<br />
<input name="submit_card_cat" type="submit"
id="submit_card_cat" value="Submit" />
</p>
</form>
When testing using the GET URL param. I see that the var
RadioGroupCardCat=1 (baseball) or RadioGroupCardCat=2 (football)
are getting passed to the card_search_results.asp page. However, I
can't seem to figure out how to capture the RadioGroupCardCat
values (1 or 2) in my SQL queries. I currently have 2 recordset
queries (rsCardCatBaseball and rsCardCatFootball) below.
rsCardCatBaseball:
SELECT tblcard.cardyear, tblcardvend.vendname,
tblcard.cardnum
FROM tblcard, tblcardcat, tblcardvend
WHERE RadioGroupCardCat=1 AND
tblcardvend.vendid=tblcard.vendid AND
tblcardcat.catid=tblcard.catid
rsCardCatFootball:
SELECT tblcard.cardyear, tblcardvend.vendname,
tblcard.cardnum
FROM tblcard, tblcardcat, tblcardvend
WHERE RadioGroupCardCat=2 AND
tblcardvend.vendid=tblcard.vendid AND
tblcardcat.catid=tblcard.catid
'catid' is the MySQL table field with either a value of 1
(baseball) or 2 (football). I'm using ASP/VBScript, so below is how
the variable is declared in the RecordSet variables area of DW.
FOR rsCardCatBaseball:
NAME
RadioGroupCardCat
DEFAULT VALUE
1
RUNTIME VALUE
Request("catid")
For rsCardCatFootball:
NAME
RadioGroupCardCat
DEFAULT VALUE
2
RUNTIME VALUE
Request("catid")
The problem is that I get the same results for both queries.
The results for the rsCardCatFootball query are identicle to the
rsCardCatBaseball query. Aren't I supposed to have 2 seperate
recordsets in the results page so that one gets passed one value
and the other RS gets the other value? Any assistance much
appreciated. Thanks.A radio group is only supposed to pass one value from the
form depending
upon which option has been clicked, therefore on the results
page you should
only need one recordset providing that everything is going
against the same
table. Providing that a value of 1 or 2 relate to the same
field then you
will be able to use the recordset dialogue box to build the
SQL.
However if different tables or fields are involved then you
will need to
handwrite the SQL statement
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver
Valleybiz Internet Design
www.valleybiz.net
"obcbeatle" <[email protected]> wrote in
message
news:[email protected]...
> After reading my original post, I see that it is was not
worded very well.
> Basically the problem I am having is understanding how
to capture values
> that
> are sent from a form to results page using Dreamweaver
MX and MySQL.
> Specifically, creating a group of two radio buttons
where two values are
> sent
> to a results.asp page that contains a Recordset Query
(using MySQL syntax)
> that
> will display the query results based on the values being
sent from the
> form
> with the radio buttons. The radio button values being
sent are either a
> '1' or
> a '2', depending on which radio button is selected and
submitted. My
> current
> understanding is that I need to have two Recordset
queries, one to capture
> each
> value being submitted. Thus I have a Recordset with a
MySQL select
> statement
> designed to capture the value '1' and display the
results, and a Recordset
> with
> a MySQL statement to capture the value '2' and display
the results. At
> present
> when I Submit the radio button values, either a '1' or
'2', I always get
> the
> display results for the Recordset Query designed to
capture the value '1'.
> So,
> I believe that either I have NOT designed the program
logic correctly in
> Dreamweaver to capture two different values using two
Recordsets, or my
> MySQL
> statement is flawed. I guess my primary questions are:
>
> 1) Should I be using two Recordsets or one Recordset in
this case?
>
> 2) If I should be using one Recordset, can anyone point
me to a sample
> MySQL
> select statement that handles two vales being submitted
from a form?
>
> I have googled extensively looking for examples of how
to do this, and
> used a
> book I have that has some examples, but NOT MySQL
examples. Any
> comments/suggestions appreciated. Thank you.
> -
Is there an easy way to find all records where an ID is found
in a list? For example if I have the following:
TABLE:
resource
FIELDS:
resourceID | listOfIDs | title
RECORDS:
1 | 1,7,9 | Item 1
2 | 2,3,7,8 | Item 2
3 | 8,17 | Item 3
4 | 2,7 | Item 4
I want to query the table for all records where listOfIDs
contains 7. This would return 1, 2 and 3. OR I may want to find
where listOfIDs contains 2 AND 8. This would return 2, 3 and 4.
Normally I would use a second table and have each one of the
list items as a record that links to the resourceID but I'm going
to have 6 different "listOfIDs" type columns so I was just trying
to see if there is a better way.
Thanks for any help.dbldutch wrote:
> Normally I would use a second table and have each one of
the list items as a
> record that links to the resourceID but I'm going to
have 6 different
> "listOfIDs" type columns so I was just trying to see if
there is a better way.
>
The second related table *IS* the better way. This is why
entire
database doctorate thesis are written on data normalization.
Trust
them, six related tables will be much easier then six columns
each
containing a list of numbers.
Why, because a list of numbers is not a list of numbers to a
database,
it is a string. And the only way to search it is inefficient
string
functions. Your where clause is going to have to look
something like this:
WHERE listOfIDs LIKE '7,%' OR listOfIDs LIKE '%,7,%' OR
listOfIDs like '%,7'
And that is just to search for one possible value in the
list, this
complexity progresses exponentially with each additional
number for
which to search. -
hii
i need a query help
i have two tables
the 1st table will look like this
associate id weekid no.of. hours
4000 810 40
4000 820 30
4000 830 60
4000 840 70
2nd table will look like this
associate id weekid no.of.hours
4000 810 40
4000 820 70
4000 830 130
4000 840 200
so when i subtract the last two records frm each other in the second table the value should be equal to the no.of.hours in the first table.. for example
the query shud consider the last record and one before the last record and the difference between two records shud be equal to the value in the 1st table
for example
consider week id 830 and 840
in second table 830=130
840=200
when u subtraced both values the difference shud be equal to value in the 1st table for tht week id
1 ---->>>> 840 - 830
=200 - 130
=70
in first table 840 has 70 hrs
like this it shud check with all records and it shud return only the records which are not equal
regards
srikanthThis..?
sql>select * from t1;
A_ID W_ID HRS
4000 810 40
4000 820 30
4000 830 60
4000 840 70
4000 850 80
sql>select * from t2;
A_ID W_ID HRS
4000 810 40
4000 820 70
4000 830 130
4000 840 200
4000 850 260
sql>
select a_id,w_id,hrs,sum_hrs
from(
select t1.a_id a_id,t1.w_id w_id,t1.hrs hrs,t2.hrs sum_hrs,
t2.hrs - nvl(lag(t2.hrs) over(order by t1.w_id),0) diff
from t1,t2
where t1.w_id = t2.w_id)
where diff != hrs;
A_ID W_ID HRS SUM_HRS
4000 850 80 260 -
Only firefox executing mysql query two times. but other browser works perfect why?
i am a web developer. and i am facing a problem only with firefox. every time i use MySQL query in my php code fire fox execute it two times. but same query is working fine on other browsers.
Yes, the problem is seen without extensions and also in safe mode.
But, I am starting to think that firefox is running low on memeory or CPU.
Without extensions the possibility of failing is 1 in 3.
I am still unable to explain why closing the browser or aborting the request can cause the stuck request to immediately reach the server.
Is there a way to collect Firefox logs and post it here ? -
Hi there. just bought a TC, installation was succesfull, but time machine won't work. can't select Backup disk. get transferred to TC install again. Called Apple, 25 min. later no succes, have to call on monday again!!!! Can anyone help me? Thanks a lot.
See #Q1 in Using Time Machine with a Time Capsule.
If you have a problem, please tell us exactly what, and on which step there. -
Help with mysql query plz anyone i am begging!!!
Hi everyone pls forgive me i am new to java. can someone pls tel me where i am going wrong wit this mysql query?
<sql:query var="parish" maxRows="1" dataSource="jdbc/gav">
SELECT ParishName, OwnerOccupierHousehold, OwnerOccupierPercOfOverall, OwnerOccupierCo2Emissions,
SocialRentedHousehold, SocialRentedPercOfOverall, SocialRentedCo2Emissions, PrivateRentedHousehold,
PrivateRentedPercOfOverall, PrivateRentedCo2Emission, TotalHouseholds, TotalPerc, Average,
Total2001, TotalEstimatedTotal2006, EmissionsPerPerson, EmissionPerHousehold, EmissionsPerParish,
EnergyChampionsNeeded, NumberOfPeopleAtWork, NumberOfSchoolAgeChildren
FROM base_data as b
WHERE b.id = ? <sql:param value="${param.id}"/>
<sql:param value="${param.id}"/>
</sql:query>
<c:set var="parish" scope="request" value="${parish.rows[0]}"/>
here is the error i get:
java.sql.SQLException: Parameter index out of range (2 > number of parameters, which is 1).
please any help would be appreciated!!! Thanks in advance guys .here is my code for the form on the index page:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="parish" dataSource="jdbc/gav">
SELECT id, ParishName FROM base_data
</sql:query>
<form action="response.jsp">
Select a Parish: <select name="id">
<c:forEach var="parish" items="${parish.rows}">
<option value="${parish.id}">${parish.ParishName}</option>
</c:forEach>
</select><br><input type="submit" value="submit" name="submit" /></form>
here is the code for the response page:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<sql:query var="parish" maxRows="1" dataSource="jdbc/gav">
SELECT b.id, b.ParishName, b.OwnerOccupierHousehold, b.OwnerOccupierPercOfOverall, b.OwnerOccupierCo2Emissions,
b.SocialRentedHousehold, b.SocialRentedPercOfOverall, b.SocialRentedCo2Emissions, b.PrivateRentedHousehold,
b.PrivateRentedPercOfOverall, b.PrivateRentedCo2Emission, b.TotalHouseholds, b.TotalPerc, b.Average,
b.Total2001, b.TotalEstimatedTotal2006, b.EmissionsPerPerson, b.EmissionPerHousehold, b.EmissionsPerParish,
b.EnergyChampionsNeeded, b.NumberOfPeopleAtWork, b.NumberOfSchoolAgeChildren
FROM base_data as b
WHERE b.id = ? <sql:param value="${param.id}"/>
</sql:query>
<c:set var="parish" scope="request" value="${parish.rows[0]}"/>
i display the results like this : ${parish.EmissionsPerParish}
the user should be able to select a parish from a form and then sql query created and then i want to show the row results on the response page.
could you tell me where so should be a simple process although not simple enough as it may seem.
thanks for the advice keith -
Series of Keychain "Login" Problems.
Hardware: Mac Mini (Late 2012) 2.5 GHz Intel COre i5, 4GB 1600 MHz DDR3
OS X : 10.10.2 upgraded yesterday
Mail wants to use "login" keychain. I enter Password but no success.
CalendarAgent wants to use "login" keychain. I enter Password but no success.
Com.apple.internetaccounts.xpc wants to you "login" keychain. Password, not successful.
At some point in past days I was offered to rename Keychain, so I did.
In Keychain Access, I deleted "Login" and selected Delete references.
Just now I went into ~/Library/Keychains and found Login.Keychain and Login_renamed.Keychain.
I have renamed Login.keychain -> Login-old.keychain.
I renamed Login_renamed.keychain-> Login.Keychain.
In Keychain Access, I added "Login" back. This should be the renamed keychain.
Original problems still persist. No noticeable changes.
Keychain wants to use the "Login" keychain. Can't remember my password or it is incorrect.
Help?
TITLprodsI turned off and turned on the computer. When restarting it said that it could not use the Login and did I want to create a new or use and alternate? I created new and for the moment things seem to be working under the command of the "New Login"
That still doesn't really alleviate the problem of the old login. -
Install maverik on my MacBook Pro, I had no problem. Two days later I was shut down suddenly and reboot with a closed padlock and asking me for a password that does not match any of mine. What can I do?
Try booting to the Recovery drive, running Disk Utility and Repair disk and Repair Permissions.
1. Reboot and immediately hold down command and R (two keys).
2. When you see the screen shown on this page, select Disk Utility and continue.
3. When DU is running, select the hard drove on the left, First Aid and Repair Disk.
4. After Repair Disk, click Repair Permissions.
Quit DU and restart. -
iPhone 4 still gets crashed even after ios 7.1 update, & sometimes fails to reboot! However it gets rebooted after 30 to 60 mins later by itself. "HELP" please somebody
1: Connect the device to Your computer and open iTunes.
2: If the device appears in iTunes, select and click Restore on the Summary pane.
Restoring > http://support.apple.com/kb/HT1414
Make sure you have the Latest Version of iTunes (v11.1.5) Installed on your computer
iTunes free download from www.itunes.com/download
Note:
Also consider Deleting any Apps you have Purchased / Downloaded but you now never use... -
Please help -- MySQL Query to Oracle
I have been trying to convert the following MySQL query to work with Oracle 9i. There seem to be two problems:
1) Oracle doesn't like the inclusion of the tblpackagegeneral.packageid in the "ON" clause of the "JOIN".
2) The "GROUP BY" only has the one field, "tblpackagegeneral.packageid", specified; Oracle wants the other two specified as well. When I do that I get a different data set than what MySQL returns for the same tables of data: specifically MySQL returns one row for each packageid but the revised Oracle version returns more than 1 sometimes.
I would appreciate any assistance possible.
/* Formatted on 2003/07/07 14:43 (Formatter Plus v4.8.0) */
SELECT tblpackagegeneral.packageid,
CASE
WHEN NVL
(COUNT (tblpackagelearnerassignment.learnerid),
COUNT (tbllearnergeneral.learnerid)
) > 0
THEN 'Activity'
WHEN tbllearnergeneral.subscribetopubliccourse = 'true'
AND tblpackagegeneral.packageaccess = 'Public'
THEN 'ActivityAfterSubscribe'
WHEN ( tbllearnergeneral.subscribetopubliccourse = 'false'
AND tblpackagegeneral.packageaccess = 'Public'
THEN 'Subscribe'
ELSE 'Subscribe'
END AS "ASSIGNSTATUS"
FROM tblpackagegeneral, tbllearnergeneral LEFT OUTER JOIN tblpackagelearnerassignment ON ( tblpackagelearnerassignment.packageid =
tblpackagegeneral.packageid
AND tblpackagelearnerassignment.learnerid =
tbllearnergeneral.learnerid
WHERE tbllearnergeneral.learnerid = '%var'
AND tblpackagegeneral.packageavailability = 'Available'
AND TO_CHAR (tblpackagegeneral.dateto, 'YYYYMMDD') >=
TO_CHAR (CURRENT_TIMESTAMP, 'YYYYMMDD')
GROUP BY tblpackagegeneral.packageid;
Sincerely,
Bill RobinsonI have been trying to convert the following MySQL query to work with Oracle 9i. There seem to be two problems:
1) Oracle doesn't like the inclusion of the tblpackagegeneral.packageid in the "ON" clause of the "JOIN".
2) The "GROUP BY" only has the one field, "tblpackagegeneral.packageid", specified; Oracle wants the other two specified as well. When I do that I get a different data set than what MySQL returns for the same tables of data: specifically MySQL returns one row for each packageid but the revised Oracle version returns more than 1 sometimes.
I would appreciate any assistance possible.
/* Formatted on 2003/07/07 14:43 (Formatter Plus v4.8.0) */
SELECT tblpackagegeneral.packageid,
CASE
WHEN NVL
(COUNT (tblpackagelearnerassignment.learnerid),
COUNT (tbllearnergeneral.learnerid)
) > 0
THEN 'Activity'
WHEN tbllearnergeneral.subscribetopubliccourse = 'true'
AND tblpackagegeneral.packageaccess = 'Public'
THEN 'ActivityAfterSubscribe'
WHEN ( tbllearnergeneral.subscribetopubliccourse = 'false'
AND tblpackagegeneral.packageaccess = 'Public'
THEN 'Subscribe'
ELSE 'Subscribe'
END AS "ASSIGNSTATUS"
FROM tblpackagegeneral, tbllearnergeneral LEFT OUTER JOIN tblpackagelearnerassignment ON ( tblpackagelearnerassignment.packageid =
tblpackagegeneral.packageid
AND tblpackagelearnerassignment.learnerid =
tbllearnergeneral.learnerid
WHERE tbllearnergeneral.learnerid = '%var'
AND tblpackagegeneral.packageavailability = 'Available'
AND TO_CHAR (tblpackagegeneral.dateto, 'YYYYMMDD') >=
TO_CHAR (CURRENT_TIMESTAMP, 'YYYYMMDD')
GROUP BY tblpackagegeneral.packageid;
Sincerely,
Bill Robinson -
My Iphone4s won't turn on! I was using it 30mins ago. Went to take a shower left it on the bed, 20 mins later I pick it up it won't turn on. I though it was dead, plug it in nothing. connect it to my PC and it says the USB is not reconignized! Help what happened??? How do I fix this!!
Try:
- iOS: Not responding or does not turn on
- Also try DFU mode after try recovery mode
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
- If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
- Try another cable
- Try on another computer
- If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order. The hotness suggests a hardware problem
Apple Retail Store - Genius Bar -
Hello, Please Help!
When I bring the mastered audio from Soundtrack pro back to final cut pro 7, the audio plays well at the beginning 3 mins later it doesn't sync.
Please Help!!!
EdgilMake sure your easy setup has the correct frame rate for your sequence. Seems crazy but somehow or other fcp assigns a frame rate to audio files. I've found this can sometimes be tricky to get right. Here's what I've done to force the issue. Make sure the easy setup frame rate reflects that of the target sequence in fcp. Create a new project. import the audio in the new project. And then copy the clip from the new project to your main project.
Good luck -
Need help writing a MySQL query that will return only records with matching counter-parts
Since I don't know how to explain this easily, I'm using the
table below as an example.
I want to create a MySQL query that will return only records
that have matching counter-parts where 'col1' = 'ABC'.
Notice the 'ABC / GHI' record does not have a
counter-matching 'GHI / ABC' record. This record should not be
returned because there is no matching counter-part. With this
table, the 'ABC / GHI' record should be the only one returned in
the query.
How can I create a query that will do this?
id | col1 | col2
1 | ABC | DEF
2 | DEF | ABC
3 | ABC | GHI
4 | DEF | GHI
5 | GHI | DEF
*Please let me know if you have no idea what I'm trying to
explain.AngryCloud wrote:
> Since I don't know how to explain this easily, I'm using
the table below as an
> example.
>
> I want to create a MySQL query that will return only
records that have
> matching counter-parts where 'col1' = 'ABC'.
>
> Notice the 'ABC / GHI' record does not have a
counter-matching 'GHI / ABC'
> record. This record should not be returned because there
is no matching
> counter-part. With this table, the 'ABC / GHI' record
should be the only one
> returned in the query.
>
> How can I create a query that will do this?
>
>
> id | col1 | col2
> --------------------
> 1 | ABC | DEF
> 2 | DEF | ABC
> 3 | ABC | GHI
> 4 | DEF | GHI
> 5 | GHI | DEF
>
>
> *Please let me know if you have no idea what I'm trying
to explain.
>
Please be more clear. You say that 'ABC / GHI' should not be
returned,
and then you say that 'ABC / GHI' should be the only one
returned. Can't
have both... -
I need help to take decision to choose between iMac Late 13 and Mac Mini Late 12
Hey guys,
I have currently got iMac 27 3.2 GHz mid 2010 and since I am a photographer it unfortunately dosn't meet my requirments at all! It has recently become too slow and that is why I have taken my decision to purchase a new desktop to improve!
I was intensely awaiting new Mac Mini Late 2013 at Apple 22 Oct event yet no new Mac Mini came up for upcoming year! Now I am very skeptical to choose between to options; iMac Late 2013 and Mac Mini Late 2012! Since having high performance is really essential for me, I am going to tune up my device with 2 Samsung 840 PRO SSD and 16GB RAM to take advantage of the best possible performance.
Since I can easily utilise my iMac 2010 27" as display for Mac Mini, please instruct me which on I should buy or I have to be more patient for next Mac Mini!
Thanks in advance!I am not sure how you are planning to "easily utilise my iMac 2010 27" as display for Mac Mini" I am concerned that might not work out nearly as well as you might think. I have seen that attempted by others and the results were pretty clunky and could easily wipe out any anticipated speed gains. Be sure and talk to someone who uses an iMac as a display for another computer before you spend any money.
That said, if I were in your shoes I would either go with a current top end iMac or a maxed out, top end Mac mini and a 27" Thunderbolt monitor. You will end up spending about the same either way. You can save a few hundred dollars buying factory refurbished machines from the online Apple Store or Smalldog.com but you take your choice of what is available and don't expect it to be there tomorrow.
Maybe you are looking for
-
SAPUI5 Application is not working in EP 7.01
Hi All, I have SAPUI5 application developed and hosted in SAP ABAP Web Application server ( GW Server), this app is already integrated with SAP Enterprise Portal 7.01 ( SP15), It is working fine without any issue in Chrome Browser. But NOT in IE11 fr
-
Compatible issues firefox v37.0.2 with att yahoo mail
6:43 PM 4/24/2015 Compatible issues firefox v37.0.2 with att yahoo mail Hello: this is my first post,hope I am doing it properly. I am using W7pro OS and ATT DSL 3.0Mbps dl I noticed this week that I was unable to save attachments from my ATT Yahoo m
-
Workflow for Order to Delivery Cycle
Hi, I need some help to find the workflows for "Order to Delivery" Cycle. I want to know whether there is any Standard workflows for this cycle from "Order to Delivery". My requirement is 1) Marketing Department Generates the Quote with a validity of
-
How to avoid Printer screen coming up after astarting a Printjob
I'm printing from JAVA with the wellknown PrintJob and Graphics classes. Everytime I call my print method the printer window appears in which I can fill in the number of copies and other properties . After pressing OK the print starts. I don't want t
-
what is the use of BELOW MENTIONED Function module IN ALV : REUSE_ALV_EVENT_GET REUSE_ALV_COMMENTRY_WRITE AND CAN U TELL ME THE BENIFITS(ADVANTAGES) AND DIFFERENCE OF CREATING A REPORT USING NORMAL AVL AND OBJECT ORIIENTED ALV(WITH OOPS CONCEPT)