Jump to content

Search the Community

Showing results for tags 'where'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Calendars

  • Community Calendar

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 6 results

  1. I am having a small issue translating my excel if statement into a CASE clause. Bellow I have posted my current SQL statement and the IF statement i am trying to fit in. I At the moment i have wrote it into the WHERE Clause but when i run it only returns the data which applies to the product description. Because of the way my where clause is set up it mean i only get half results where as i want it to show if column a does not match criteria then look for certain items in column b IF Statement is =IF(PD="AC","S",IF(PD="CS","S",IF(PD="CA","S",IF(**PT="SS","S"," ")**))) Current SQL SELECT AEOrdersReceivedCurrentQuarter.`Order Company` , AEOrdersReceivedCurrentQuarter.`Sop Order Number` , AEOrdersReceivedCurrentQuarter.`Order Date` , AEOrdersReceivedCurrentQuarter.`Order Method` , AEOrdersReceivedCurrentQuarter.`Payment Method` , AEOrdersReceivedCurrentQuarter.`Product Type` , AEOrdersReceivedCurrentQuarter.`Product Sub Type` , AEOrdersReceivedCurrentQuarter.`Product Description` , AEOrdersReceivedCurrentQuarter.`Quantity Ordered` , AEOrdersReceivedCurrentQuarter.`Product Item Value` , AEOrdersReceivedCurrentQuarter.`Order Count` , AEOrdersReceivedCurrentQuarter.`Order Item Narrative` , AEOrdersReceivedCurrentQuarter.`Product Group` , AEOrdersReceivedCurrentQuarter.`Product Category` FROM AEOrdersReceivedCurrentQuarter.csv AEOrdersReceivedCurrentQuarter WHERE (AEOrdersReceivedCurrentQuarter.`Product Type` = 'Studio Services' OR AEOrdersReceivedCurrentQuarter.`Product Description` IN ('Artwork Charge','Creative Services','Creative Agency','Studio Services') )
  2. Hi – I’m having a lot of trouble with a where clause with a date in my sql query. It seems I have tried everything and read many articles & blogs, but I can’t get it working. I understand the data type is very important to match up and the format also. Anyway I’ll tell you what I’ve got and see if anyone can help me. I’m joining 3 tables in my query – everything works fine and I get the results I want UNTIL I add the where clause. Unless there is something I need to change because of the where clause, I shouldn’t need advice on that. Tables Fields Kiosks – kioskID, workDate, locationID, workerID, bills, coins - workDate is type Date Locations - locationID, storeName, branchName, locationAbbrev Workers - workerID, firstName, lastName, phoneNum $sql = "SELECT Kiosks.kioskID, Kiosks.workDate, Locations.locationAbbrev, CONCAT(Workers.firstName, ' ', Workers.lastName) AS workerName, Kiosks.bills + Kiosks.coins AS amount FROM Locations INNER JOIN Kiosks ON Locations.locationID = Kiosks.locationID INNER JOIN Workers ON Kiosks.workerID = Workers.workerID”; This part works fine and I get a long list showing the Date, Location, Worker, and Amount using PHP. BUT,(everybody’s got a big BUTT) when I tack on the Where clause – kapoof!! When I try different formats I get either 0 results or unable to process messages. Here are a couple of things I’ve tried – hopefully someone can spot the error in my ways. Thanks $sql = "SELECT Kiosks.kioskID, Kiosks.workDate, Locations.locationAbbrev, CONCAT(Workers.firstName, ' ', Workers.lastName) AS workerName, Kiosks.bills + Kiosks.coins AS amount FROM Locations INNER JOIN Kiosks ON Locations.locationID = Kiosks.locationID INNER JOIN Workers ON Kiosks.workerID = Workers.workerID WHERE Kiosks.workDate = '2017-12-05'"; Also tried without quotes like = 2017-12-05 $sql = "SELECT Kiosks.kioskID, Kiosks.workDate, Locations.locationAbbrev, CONCAT(Workers.firstName, ' ', Workers.lastName) AS workerName, Kiosks.bills + Kiosks.coins AS amount FROM Locations INNER JOIN Kiosks ON Locations.locationID = Kiosks.locationID INNER JOIN Workers ON Kiosks.workerID = Workers.workerID WHERE year(Kiosks.workDate) = 2017 AND month(Kiosks.workDate) = 12 AND day(Kiosks.workDate) = 5";
  3. Hi all, I have a question about join or inner join; not sure in what way it should be used. I now use 2 queries in 2 different databases (made in phpmyadmin). SELECT `title` FROM `writers` WHERE id ='qwert58efedd1979f'; SELECT `name`, `lastname`, `str`, `nr`,` place` FROM `client` WHERE id ='qwert58efedd1979f'; I would like to make one mysql query and use join to search in 2 tables in 2 different databases. Can anyone tell how mysql does this?
  4. hi, sorry, i have a question to do...but i know how to write in sql query ....however the answer need to write on relational algebra in query is like : SELECT * FROM operation where r='broken' group by pc having count(pc) >1 ; π id,pc,result ( σ r = 'broken' (operation)) like group by and having clasue...i no idea ... i searched on internet still @@ .... isnt the answer like that, i using split/step by step method to do rel 1 = σ r = 'broken' (operation) rel 2 = σ count(pc)>1 γ pc,count(pc) (rel 1)) rel 3 = π id,pc,result (rel 2 ) thanks
  5. ok, just quick... im getting this when trying to login: Unknown column 'e5035533a816cac4c54012281f58543d' in 'where clause' and this is my takelogin.php file: /*==========RUN LOGIN PROCEDURE===============*/$uname = sqlesc($_POST['username']); /*Form Names...*/$pass = sqlesc($_POST['password']); /*Form Names...*/if(isset($pass)){$passhash = md_5($pass); /*Securing The Data...*/}$query = "SELECT * FROM users WHERE username = $uname AND passhash = $passhash AND enabled = 'yes' AND status = 'confirmed'";$query_result = mysql_query($query)or die(mysql_error());//Running query to the DB...if(mysql_num_rows($query_result) == 1)/*if the DB returns somfthing, then run...*/{$row = mysql_fetch_array($query_result);$_SESSION['uid'] = $row['u_id'];$_SESSION['username'] = $row['username'];$_SESSION['pass'] = $row['passhash'];$_SESSION['status'] = $row['status'];$_SESSION['enabled'] = $row['enabled'];$_SESSION['email'] = $row['email'];$_SESSION['ip'] = $row['ip'];$_SESSION['class'] = $row['class'];$_SESSION['time_offset'] = $row['time_offset'];$_SESSION['dst_in_use'] = $row['dst_in_use'];$_SESSION['auto_correct_dst'] = $row['auto_correct_dst'];header('Refresh: 3; url=index.php');//with time delay...}else/*Error messeage...*/{$HTMLOUT .= "<center>Error reading login-session coding base, or a wrong username/pass inserted...</center>";header('Refresh: 3; url=index.php');//with time delay...}/*==========RUN LOGIN PROCEDURE===============*/ any ideas? Oo...
  6. I’m new to writing SQL, and most of my needs so far have been met in the wonderful w3 SQL tutorial. However, I have a desire I haven’t been able to find a way to do, and I can't find info on it in the forums either. I have 3 inner joined tables in the part of the code I’m struggling with. ClientsView EmployeeClients Employees For a given client (identified by ClientsView.client_id) there are many employees linked to the client. I want to search those employees and return in a single column “Primary_Staff” the employee assigned to the client who meets certain criteria. In all cases the field EmployeeClients.primary_flag will need to be “YES”. The kicker is that what I want it to look for is first to see if an employee is found where the Employee.profile_code = “MHP”. If so, that is the employee I want listed in the new “Primary_Staff” field. If no one is found with that profile code, then I want it to search the employees to see if any is found where Employee.profile_code = “On Call MHP”. Then Employee.profile_code = “LPE”. And a few others, but that’s enough for the example. If it goes through the list of profile codes I’m looking for and doesn’t find anyone, then I just want it to say “Unassigned.” Thanks in advance for the help, and let me know what other information is needed if you need more info to be able to give me some help.
×
×
  • Create New...