This is a function that I wrote and have re-used many times. I share it with you DaniWebers to use, laud or destroy! In a nutshell, this takes a user's search box input phrase and generates a series of LIKE clauses for your SELECT statement. Looks like "col1 LIKE '%s_term1%' OR col1 LIKE '%s_term2%' OR col2 LIKE '%s_term1' .." The column names you want it to use is the second parameter of the function.

Member Avatar
+1 forum 0

Hi, How to use in select statement with where condition comparing a Null value and with value? I have this Statement `Select Col1, Col2, Col3 From Table where DateDeleted` 'Here comes the problem The condition is something like if DateDeleted (which is actually a date) is Null then get records with null DateDeleted, else it should compare the DateDeleted to specified date. If this DateDeleted is less than (or earlier) than the specified date then it will show the records, else it bypass it. The idea of the select statement is to get all data with null DateDeleted and those …

Member Avatar
Member Avatar
+0 forum 7

Hi. I have a mysql field with a record like: [2,5,11]. I have a query like: $query = $this->select() ->from($this->_name) ->where('id = ?', $id); This query work if record is of integer type: 5. Is it possible to create a query to find 5 in the array? Please advise. Thanks.

Member Avatar
Member Avatar
+0 forum 5

Hi All, Firstly I will say that this exercise is for my learning experiences through an online course. However I have spent a combined total of about 6 hours working on this question and I am completely stumped on how to get the correct answers. The question: > List the Title, Name and date of appointment for Governors General of Australia who were appointed between 01 January 1930 and 01 January 1960, together with the Prime Ministers who appointed them and all Leaders of the Opposition who served during their appointment. The date is to be formatted in dd/mm/yyyy format. …

Member Avatar
Member Avatar
+0 forum 2

Hello Experts, First I want to thank you all.I am getting all responses at this Daniweb :) My problem is that I have a sql statement where I want to add where clause in case of dropdown is changed. My database connection part: <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/_database.accdb" SelectCommand="SELECT * FROM [Devices] WHERE ([feature1] = ?)"> but I don't want that * WHERE ([feature1] = ?) * exist there. I want that it only added there when i click to the below radio button <asp:RadioButtonList ID="feature1" runat="server" AutoPostBack="True" DataSourceID="AccessDataSource10" DataTextField="feature1" DataValueField="feature1"> </asp:RadioButtonList> As far as I understand I should write some …

Member Avatar
Member Avatar
+0 forum 3

Hello everyone! Is it possible to write a query which does the following : UPDATE db.table SET col1 = 1 WHERE col2='something' AND col3 IN ('a','b','c') ELSE SET col1 = 0 Meaning that the rows that don't match the where conditions will also be updated to another value. Note that db.table has no primary key, but foreign key only. :S edit : I am looking for a single query of course! Thanks in advance!

Member Avatar
Member Avatar
+0 forum 4

Hello I have databse in MySQL with 21 fields which are listed below Field Name Data Type NULL status text No roll_no text No branch_id int(5) No student_name text No father_name text No phone1 text No phone2 text No email text No dob date No city text No course_id varchar(5) No class_id int(2) No program text No duration text No comment text No admission_year int(4) No admission_date text No entryby text No address text No admission_no int(4) No fees int(6) No Now I am stuck with search process, I bit confused, how can I perform search for different types of …

Member Avatar
Member Avatar
+0 forum 3

Good day, I am having trouble with my condition, i dont know where should i put where in my query here is my code.. SELECT distinct MATERIAL ,Description ,Material_Type -- ,Requested_Delivery_Date ,ATP_check ,Delivering_Plant ,Order_Quantity ,Held_by_Finance ,Rejected_OOS ,Rejected_Others ,ISNULL(Open_Order_Quantity,0) AS Open_Order_Quantity ,ISNULL(Order_Quantity_NKA,0)as Order_Quantity_NKA ,ISNULL(Order_Quantity_RKA,0) AS Order_Quantity_RKA ,ISNULL(Order_Quantity_Others,0) AS Order_Quantity_Others ,ISNULL(Stock,0) AS Stock ,ISNULL(DSD_Delivery,0) AS DSD_Delivery ,ISNULL(OUtBound_Haulage,0) AS OUtBound_Haulage ,ISNULL(Total_OutBound_items,0) AS Total_OutBound_items ,ISNULL(InBound_Haulage,0) as InBound_Haulage ,ISNULL(Haulage_In_Transit,0) AS Haulage_In_Transit ,ISNULL(Process_Order,0) AS Process_Order ,ISNULL(Total_Inbound_Items,0) AS Total_Inbound_Items --pivot ,ISNULL([IN TRANSIT],0) as [IN TRANSIT] ,ISNULL(HAULAGE,0)as HAULAGE ,ISNULL(PRODUCTION,0) as PRODUCTION --computation ,(ISNULL(Haulage_In_Transit,0) * ISNULL([IN TRANSIT],0))/100 as Custom_Haulage_In_Transit ,CONVERT(INT,(ISNULL(InBound_Haulage,0)) - ISNULL(Haulage,0) / 100) as Custom_Inbound_Haulage ,CONVERT(INT,(ISNULL(Process_Order,0) * ISNULL(PRODUCTION,0))/100) …

Member Avatar
Member Avatar
+0 forum 2

Hi so I'm making a site for sneakers. A person can sign up and say they like Nikes, Vans, Reeboks, etc. I then have it where you can make a group for people who like certain sneakers as well. So the group can say they like Nikes, Vans, Reeboks, etc. I want to get the group likes (Nikes, Vans, Reeboks, etc.) and search the users database for anyone who likes Nikes, Vans, or Reeboks. I can get it where it searches only one like, but can't do it for multiple.

Member Avatar
Member Avatar
+0 forum 5

Ok let say i have the following xml file <Users> <User> <Name>David</Name> <Attempts> <Place>Paris</Paris <Date>3/29/2012</Date> <Duration>50 seconds</Duration> <Distance>100</Distance> </Attempts> <Attempts> <Place>New York</Paris <Date>7/28/2012</Date> <Duration>30 seconds</Duration> <Distance>100</Distance> </Attempts> <Attempts> <Place>Paris</Paris <Date>8/19/2012</Date> <Duration>70 seconds</Duration> <Distance>60</Distance> </Attempts> <Attempts> <Place>New York</Paris <Date>9/29/2012</Date> <Duration>60 seconds</Duration> <Distance>200</Distance> </Attempts> </User> <User> <Name>Lenny</Name> <Attempts> <Place>Paris</Paris <Date>9/29/2012</Date> <Duration>51 seconds</Duration> <Distance>130</Distance> </Attempts> </User> </Users> So what im trying to find is particular data between 2 time frames depending on what user i chose from a drop down list Let Say i chose Daniel and i chose a timeframe from a starttextbox to be 2/20/12 and a endtextbox to be 9/30/12 …

Member Avatar
Member Avatar
+0 forum 4

Hello everyone. I need some help with a SELECT FROM WHERE query. Let's say I have a row named A and another row named B, and I want to select the eventual cases where values from these two rows, somewhere, match eachother. In this case, you can see, that the only value that you can find in the both rows is '1'. (Check the table below). How can I make a SELECT statement out of this, where I want to sort out these occasions on when there are values of the same in the two rows? SELECT * FROM `table` …

Member Avatar
Member Avatar
+0 forum 4

$u = mysql_real_escape_string($_POST["username"]); $p = sha1($_POST["passwd"]); $q = "SELECT * FROM profile WHERE email=`$u` AND passwd=`$p`"; $run = mysql_query($q); if(!$run){ echo mysql_error(); } this creates *Unknown column 'mymail@gmail.com' in 'where clause'* error. This code is from a tutorial and a piece of a submit-new-post php page.

Member Avatar
Member Avatar
+0 forum 2

I am trying to create a where clause that loops through my foreach loop. The idea is to have a search with four possible values depending on which values the user fills in. ,<?php $fname = $_GET['fname']; $lname = $_GET['lname']; $nature =$_GET['nature']; $ticket_id = $_GET['ticket_id']; $nbsp = " "; $fields = array('fname', 'lname', 'ticket_id', 'nature'); $whereClause = "WHERE" ; foreach ($fields as $field) { if(isset($_GET[$field]) and !empty($_GET[$field])) { $whereClause .= $field . " LIKE '%" . $_GET[$field] . "%' OR "; } // else { return "no results found"; // } } substr($whereClause, 0, -4); $query = ("SELECT fname, lname, …

Member Avatar
Member Avatar
+0 forum 9

Of course this is a hypothetical scenario. Let’s suppose that you can’t choose last three or four decades, and that you can’t choose to be a historical (real or imaginary) figure so when in history would you choose to live, where and why?

Member Avatar
Member Avatar
+0 forum 19

Hello, I'm trying to get results from a mysql database based on values in an array. My tables look like this 1. id | articles | thumbs | etc 2. tag_id | tag_name | article_id I'd like to get related articles based on the tags for that particular article. So if an article has books, drawings, cartoons for tags, then I would like to get articles from the database that have those exact tags, only. I have this query below which gets related articles if an article has ONE or MORE of the tags associated with it. $tagcom=array("books","drawings","cartoons"); $tagcoms = …

Member Avatar
Member Avatar
+0 forum 1

During some recent project issues I found myself asking this very question: **Does MySQL short circuit WHERE clause statements?** After doing some research and finding that several other people and technical forums have posed this question, with several answers pertaining to be intelligent but that amount to *"i don't know"*, I decided to perform some experiments. Firstly, how to test whether a statement is being executed or not? Solution: make it throw an exception. I initially tried some select statements with parameters and division by zero, but MySQL apparently returns NULL instead of a divide-by-zero error. So I came up …

Member Avatar
Member Avatar
+0 forum 3

Hi, I have a doubt in MS SQL, The below condition in the WHERE clause as you can see, "Where COTDetails NOT BETWEEN 32 AND 63 OR COTDetails is NULL", I want to the WHERE clause in such a way that the COTDetails is not between 32 and 63 and also is NULL, OR condition does not satisfy my condition. Any help appreciated

Member Avatar
Member Avatar
+0 forum 5

Hi, I am having a problem in making a query. I have a table in which dates are saved in varchar format and I want to compare these dates in my search query. I want to take two input dates from the user i.e. starting date and ending date and I want to compare these dates with my varchar fields in which dates are saved. As far as I know we cannot compare dates if they are in varchar format. I made a query for this SELECT id,start_date,end_date FROM dates WHERE (start_date,'%m/%d/%Y')>='2012-01-01' AND (end_date,'%m/%d/%Y')<='2012-12-01' I have values in my table …

Member Avatar
Member Avatar
+0 forum 4

The End.