Jump to content

sqlmc

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

sqlmc's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I think UNION wasn't supported until version 4, I ran a similar query on a 3.23 system and a 4.1 system and the UNION worked on the 4.1 system and failed on the 3.23. You may have to separate the queries and then put them together after you gathered the appropriate info.
  2. It looks like your using a varialbe for an alias. Try this. $sql11 = "SELECT Company FROM Enq WHERE Enqid='$enq' UNION SELECT Company FROM Visit WHERE Visitid='$enq'"; $result11 = mysql_query($sql11) or die (mysql_error()); $myrow11 = mysql_fetch_array($result11); $company = $myrow11["Company"]; Also what is the datatype for Visitid and Enqid? You're using single quotes, but if the field is numeric then this may cause an error. If these fileds are INTEGER for example remove the single quotes from the WHERE clause.
  3. Try adding the remaining selected attributes to your group by clause. So it would go something like this. Select distinct labor.Dept AS DEPT, labor.Job AS MS, countsheet.PART_NUMBER, Sum(labor.Total) AS DEPT_HOURS, countsheet.TOTAL AS TOTAL_QTY, countsheet.DUE AS UNCOMP_QTY, countsheet.NET AS COMP_QTY From labor,countsheet Where labor.Job = countsheet.MS Group By labor.Job, labor.Dept, countsheet.PART_NUMBER, countsheet.TOTAL , countsheet.DUE , countsheet.NET Order By countsheet.MS Asc ; Oh, and I'm not seeing where countsheet.MS is being selected. Using an attrute in an Order By cluase that hasn't been selected may cause unexpected results.
  4. I would try removing the single quotes from the table and attribute names. Also your using a LIKE statement without a wildcard. So try something like this. $result = mysql_query("SELECT * FROM general WHERE header LIKE '%header%' " ); In this example you should get results from your talbe where the attribute header contains a value with the string 'header' within it.
  5. Is your table structure for Enq and Visit is the same? If not, the UNION with a SELECT * may cause problems. If you only need a particualr value, or even multiple values try using aliases that match and that should work. So it would go something like this. SELECT Attribute_A as NeededValue FROM Enq WHERE Enqid='$enq' UNION SELECT Attribute_B as NeededValue FROM Visit WHERE Visitid='$enq
  6. What version of Dreamweaver are you using?
  7. With this table structure I would try something like this: SELECT A.team1 ,B.teamname as team1 ,A.team2 ,C.teamname as team2 FROM matchups A JOIN teams B ON A.team1 = B.id JOIN teams C ON A.team2 = C.id /*A B and C are table aliases which I used just to cut down on typing*/
  8. Try this: SELECT * FROM db LEFT JOIN db2 ON db.field1 = db2.field1 AND db.field2 = db2.field2
  9. At what level of information are you looking for? If you using a newer version of MySQL you might try nested subquireis in your joins and then have each subquery use count(*), but can the information you're looking for be counted only once or does it require more than one value?
  10. I would try using an alias so it would go something like this: SELECT SUM( boardfee ) AS board_sum FROM boarded WHERE boarder = 'Duli'"; /*************************************************************/ As for summing the two columns it would go something like this: SELECT SUM( boardfee ) + SUM(ExtraFees) AS total_sum FROM boarded WHERE boarder = 'Duli'"; /*************************************************************/ Something else you may want to use with this or any other aggregate function is a group by clause.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.