FAQ Database Discussion Community


T-SQL: Check if date is in proper format within Where-Clause

sql,tsql,select,where
How is it possible to check within the where-clause, if the date parameter is set and if it's in the proper format (dd/mm/yyyy). Here is my SP with parameter @birthdaysearch in format (dd/mm/yyyy): Select * From Clients as c WHERE CASE ISDATE(@birthdaysearch) WHEN 0 THEN (c.BirthDay LIKE '%') WHEN 1...

MS Access WhereConditions in xml export

sql,xml,ms-access,report,where
I'm trying make an XML export of Report. It works, but I cant make filter criteria. I want to filter by DATE, 4 months to the past. Dim sXMLPath As String sXMLPath = "z://export1.xml" ExportXML acExportReport, "export1", sXMLPath, , , , , , [DATUM] > Date - 120 And [DATUM]...

Laravel where on relationship object

php,laravel,eloquent,where,relationship
I'm developing a web apis with Laravel 5.0 but I've got a doubt about a query. My classes are these: class Event extends Model { // protected $table = 'events'; public $timestamps = false; public function partecipants() { return $this->hasMany('App\Partecipant', 'IDEvent', 'ID'); } public function owner() { return $this->hasOne('App\User', 'ID',...

Having trouble with SQL 'in'

php,mysql,sql,where
I want to search for all records in product_description who match a certain brand, and also whose status in another table product is '1'. This is how far I've got, but I'm tripping up somewhere: SELECT brand, name, product_id FROM product_description WHERE brand = $brandname AND product_id IN (SELECT product_id,...

How to add data to table that is existing [closed]

php,mysql,sql,where
if (file_exists(TEMP.'/'."$check_dir".'/'."$endofname$test".'.jpeg')) { echo "File : $endofname$test was made <br />"; move($new_file_destination); $img_name = 'http:localhost/single4thenight/media/com_jomclassifieds/items/backpage/'."$check_dir".'/'."$endofname$test".'_1.jpeg, '; $img_title = "UPDATE iutca_jomcl_adverts SET images='$img_name' WHERE title='$title'"; if ($conn->query($img_title) === TRUE) { echo "Record updated successfully"; } else { echo "Error updating record: " . mysqli_error($conn); } } I need to add data...

not letting me insert values with a where clause

php,mysql,pdo,where,mariadb
I'm making forums and I'm trying to make it so when you reply to a topic it will put the reply information in a table (WHICH WORKS) and then it will INSERT values into the subcategories table WHERE the subcategories ID is equal to this subcategories ID. CODE: $query =...

Postgres - WHERE clause on whether values contain a certain string

sql,string,postgresql,where
If I want to retrieve all entries such that the column foo value contains a string 'bar', is there a simple way to do this in SQL, or Postgresql? Something like ' WHERE foo = "bar"' but instead of = it would be something like ' WHERE foo CONTAINS "bar"'....

Selecting referenced column entries with SQLITE3: Ignored WHERE-clause

sqlite3,where
I have the following sqlite3 tables: CREATE TABLE bilder (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL); Data: __id__ 8 9 10 11 And CREATE TABLE combos (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL); Data: __id__ 1 2 3 4 And CREATE TABLE combo_bild (combo_id int not null references combos(id), bild_id...

How to get All bit field value in SQL Server in stored procedure

sql-server,stored-procedures,where,bit
I have been searching but still not get the best way to do this I have a table with sex column (bit) so the value will be 1/0/null My stored procedure with parameter @sex SELECT * FROM [dbo].[data] WHERE sex = ISNULL(@sex, sex) When I'm send @sex null, the query...

IF in WHERE clause

if-statement,delete,chat,where,messages
del=0 - not deleted, del=1 - sender and reciever deleted message, del=2 - sender deleted message, del=3 - receiver deleted message. My code is SELECT * FROM messages WHERE (`from` = :owner AND `to` = :partner) OR (`from` = :partner AND `to` = :owner) AND IF(`from` = :owner,`del`=3 OR `del`=0,`del`=2...

SELECT DISTINCT user_id of highest value in support_date WHERE

mysql,sql-order-by,max,distinct,where
tb_supporters: user_id support_date ----------------------------- 1 1301283373 2 1301283743 3 1301799207 1 1403862904 2 1405174895 3 1415266390 As the result of the query, it should output the highest support_date of each unique user_id. My actual query: "SELECT DISTINCT(user_id), support_date FROM tb_supporters WHERE support_date < " . (time() - 60*60*24*7) However, it's...

WHERE clause with INSERT statement, “Incorrect Syntax” at the WHERE, and IF NOT EXISTS running regardless of if record exists

sql,sql-server-2008,where,sql-insert
I have this INSERT query: INSERT INTO Appointments (StaffID, CustomerID, TimeSlot, AppDate) VALUES (1, 11, 1, DATEADD(day, 1, GETDATE())) WHERE NOT EXISTS (SELECT * FROM Appointments WHERE StaffID = 1 AND CustomerID = 11 AND TimeSlot = 1 AND AppDate = DATEADD(day, 1, GETDATE())); Yet it says "Incorrect syntax near...

Find a Portion of a Database in Ruby

ruby,database,ruby-on-rails-3,object,where
Say for example I have the following database of instances of a class called Obj: | id | attr1 | +----+-------+ | 10 | A | | 15 | B | | 20 | C | | 50 | D | Now let's say I want to find all of...

Rails 4 find data where the date is the last day of the month

ruby-on-rails,date,ruby-on-rails-4,where
Using Rails 4, I have a set of data where I only want the data points where the date is on the last day of the month, any month, but only where the date is the last day of the month. Below I set up the @data variable all my...

MySQL column UPDATE data subsitution using IF (# 1054 - Unknown column in 'where clause')

mysql,if-statement,where
I hope your day is going better then mine. I thought I had an easy task this morning to combine two tables in mysql (Distrib 5.5.43, for debian-linux-gnu) based on a common column. Basically the structure is as follows: Practice1 Hip Description Purchaser Price 1 Bill Smith Sam Dillon $300,000...

Basic SQL Statement (Where)

sql,where
I have one table named products with the next tuples: type code gestion situation subfamily And I want to select type, code, gestion, situation, where subfamily are different values; 994, 948, 931. What I have done: SELECT type, code, gestion, situation FROM products WHERE subfamily = 994 AND subfamily =...

How to avoid using a subquery

sql,subquery,where
Here a sample table : A | B ---------- DF RUI EF RUI AF FRO EF FRO I want to get all results except WHERE (A = 'EF' AND B = 'RUI') like this : A | B ---------- DF RUI AF FRO EF FRO But is it possible to...

Result of findBySQL in Yii

php,mysql,yii,where,find-by-sql
Query "SELECT * FROM uzytownik" in phpMyAdmin gives me all recodrs from uzytkownik table. But this same query applied in yii controller gives me olny one (first) record. What is wrong? class StronaController extends CController { public function actionIndex() { $model = new Uzytkownik; $wynik = $model::model()->findBySQL('SELECT * FROM uzytkownik');...

Dynamically add like operators in where clause

sql,where,like
Can any one give me a solution for my problem? I have a string array of max length. I want compare all of my string array elements with a single SQL query. How can I do that? string[] new = searchtext; select Qid from questions where qdescriptions like string[0],string[1],string[2] The...

A multiple conditioned count

sql,if-statement,where,business-objects,rich-client-platform
I have a list of references in a database. If the reference exists in a month then it is rated either a 1 or a 99. If the reference does not exist then it gets a rating of 0. Each 3 months forms a quarter. In the rich client I...

C# predicate list passed to linq Where clause

c#,linq,where,predicate
I have a long linq .where clause that I would like to populate with a predicate list. List<Expression<Func<Note, bool>>> filters = new List<Expression<Func<Note, bool>>>(); filters.Add(p => p.Title != null && p.Title.ToLower().Contains(searchString)); filters.Add(p => p.Notes != null && p.Notes.ToLower().Contains(searchString)); filters.Add(GlobalSearchUser((List < User > users = new List<User>() { p.user1, p.user2, p.user3,...

MYSQL: How to use the result of a grouped SUM() as condition in WHERE clause?

mysql,sum,where
In my Table of TEAMS with relational table>rows for its PLAYERS Each Team has 3 or more players Each Player associated with the team has a points column I need to retrieve only the TEAM w/c has accumulated player points of 300 or greater I have gone to this point...

Laravel Eloquent ORM - Complex where queries

php,database,laravel,orm,where
I have the following query: DB::select("SELECT * FROM mod_dns_records WHERE (scheduled = 'N' AND scheduleTime = 0 AND domainId = {$id}) OR (deleteRow = 'Y' AND domainId = {$id})"); However, this is not safe against SQL injection. Could someone help me to make this safe, or tell me how to...

Update values in column across multiple tables using where

sql,sql-server,where
I have a database that contains data for multiple divisions within a company. Each division is given a code that allows certain data elements to be exclusive to them. This code is housed in the 'agency' column. Not all tables have an agency column, but I do not know which...

MySQL query with less than and ORDER BY DESC

mysql,indexing,sql-order-by,where,where-clause
I'm doing some work with a rather large set of data and am trying to create a query from every combination of four different pieces of data. All of those pieces combined form a staggering 122,000,000 rows. Then, I'm trying to find a weight that is less than a certain...

Mysql SELECT with WHERE clause not working with variable

php,mysql,variables,select,where
I am pulling my hair out. I have two SELECT statements that are basically the same principal. The first one is working and the second one will not work with the WHERE clause in it. I need some fresh eyes and suggestions. I have been on every forum and read...

Combining two select statements

sql,database,select,where
I have two statements as such: var chgAssociationQuery1 = (from a in sostenuto.PROBLEMS join b in sostenuto.S_ASSOCIATION on a.SERVICEREQNO equals b.FROMSERVICEREQNO join c in sostenuto.Changes on b.TOSERVICEREQNO equals c.SERVICEREQNO where b.FROMSERVICEID == 101001110 && b.TOSERVICEID == 101001109 && a.NAME.Contains(name) select new { ProblemReqNo = a.SERVICEREQNO, ProblemId = a.SERVICEREQID, ChangeReqNo =...

Linq statement with 2 joins a where and need a count

c#,linq,join,count,where
This is what i have: var count = (from p in _db.Personen join pc in _db.Postcodes on p.Postcode equals pc.postcode join r in _db.Regios on pc.RegioId equals r.RegioId where (p.Leeftijd >= leeftijdgetal[0] && leeftijd[1] <= p.Leeftijd) && r.RegioNaam == regio && p.Geslacht == geslacht select new { teller = Where(p...

SQL- WHERE and HAVING

sql,where,having
our task is to replace GROUP BY and HAVING clauses with WHERE, if possible. SQL-Code is as follows: SELECT Sparte , Region , SUM( Umsatz ) FROM Fakten GROUP BY Sparte , Region HAVING SUM( Umsatz ) >= 50000 Is it possible to change the last two lines using WHERE?...

WHERE NOT EXISTS check and equals to “=” check fail together but work seperatly

sql,sql-server-2008,where,not-exists
I have an INSERT SQL query which needs to check if the entry will cause double booking, and that also the 2 users (doctor and patient) are affiliated with the same clinic. (Found it easier to explain in regard to the scenario), the SQL I have is: WITH ins (MedStaffID,...

MySQL WHERE clause selects values then omits some based on another column?

php,mysql,where
I have a pretty simple question (I think) but I can't seem to find an answer anywhere. I'm sure I'm over-thinking this but I would like insight nonetheless. Using MySQL, I would like to SELECT rows in a table based on a column using a WHERE clause and then refine...

Is it possible to use the current dayname in the where clause in MySQL?

mysql,where
I am trying to create a view in MySQL based on the current day of the week. I am creating a table to keep track of tasks based on the day of the week. For example, some tasks will happen every Tuesday, some will happen on Wednesday and Friday, etc....

Which performs first WHERE clause or JOIN clause

sql,sql-server,select,join,where
Which clause performs first in a SELECT statement? I have a doubt in select query on this basis. consider the below example SELECT * FROM #temp A INNER JOIN #temp B ON A.id = B.id INNER JOIN #temp C ON B.id = C.id WHERE A.Name = 'Acb' AND B.Name =...

mysql query to select all rows which satisfy a given input range and for multiple inputs

mysql,sql,where,multiple-select
I need to find the number of rows which satisfy the given condition for a list of input values. Suppose we have a table with columns id,open_date,close_date. request table id open_date close_date 1 '2013-04-08' '2013-04-10' 2 '2013-04-11' '2013-04-12' 1 '2013-04-09' '2013-04-12' 1 '2013-04-10' '2013-04-12' Now I would want to the...

OrientDB - LET variable in where

where,orient-db,let
I have a query very similar to this: SELECT FROM Post LET $category = (SELECT EXPAND(out('PartOf')) FROM $current), $poster = (SELECT EXPAND(in('Posted')) FROM $current) WHERE $poster <> #18:1 AND $poster IN (SELECT EXPAND(out('IsUser')) FROM (SELECT EXPAND(out('Related')) FROM #18:1) WHERE out('RelatedIn') IN ($category)) LIMIT 10000 And a graph like this: CREATE...

MYSQL where clause causes syntax error

mysql,syntax,where,clause
I just cannot find what is wrong with this simple statement: $stat_qry = mysql_query("SELECT * FROM stats WHERE group=$galgroup") or die("STATS ERROR: ".mysql_error()); $stat = mysql_fetch_array($stat_qry); i just get: "STATS ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for...

mysql - select from 2 tables, count and group by column

mysql,select,count,where
So I have 2 tables: pages: id page visit_id 1 6 65 2 7 65 3 2 66 4 10 67 visits: id flipbook 65 april 66 april 67 may I want to return how many pages were viewed for each flipbook: april: 3 may: 1 My query looks like...

How To Use The Where & Like Operator Together in SQL?

sql,ms-access,where,like
I want to display a List of Instructors with only first name and last name, from Georgia and whose last name ends in ‘son’. I have written this so far: SELECT firstname, lastname, state FROM instructors WHERE state = 'ga' AND lastname LIKE '%son' But it is not returning the...

MySQL WHERE variable

php,mysql,where
i have this sting for example: 11,22,33 and this is me table: ID / content --------------------- 1 / 11,15,18,20,22,28,29,30, 2 / 10,11,17,20,22,27,33,40, 3 / 4,8,9,15,22,23,24,31,33, 4 / 10,11,20,22,30,33,40,41, 5 / 5,6,7,10,11,22,28,30,33, 6 / 10,11,12,13,14,15,20,22, id 1 contains only 11 and 22 id 2 contains all items from strin: 11 and...

Where by month in codeigniter

codeigniter,where
I have this code $where = array('MONTH(c.cashDate)' => 'MONTH(NOW())'); $data['dataCash'] = $this->cash->cashList($where); but it doesn't work, its create query like this SELECT `c`.`cashId`, `c`.`cashDescription`, `c`.`cashDate`, `c`.`cashCategory`, `a`.`category`, `c`.`cashValue`, `t`.`typeid`, `t`.`type` FROM (`cash` c) LEFT JOIN `cashCategory` a ON `c`.`cashCategory` = `a`.`categoryId` LEFT JOIN `type` t ON `a`.`type` = `t`.`typeid` WHERE...

Haskell local function Is not in scope

function,haskell,where,local
The following function is supposed to return the sum of all the polynomials in a list having a polynomial as a list of floats. (ie: 4x²+2x+1 would be [4,2,1] and 5x⁵+x+2 [5,0,0,0,1,2]) psum :: [[Float]] -> [Float] psum (x1:x2:xs) = psum (binpsum (x1, x2)):xs psum x = x where binpsum...

SQL Server Insert with where clause

sql,sql-server,where
I have a query like this: Insert into Table1 (Code) Values ('ss23') Where Table1.sequence between '0' and '999' I get the following error : Incorrect syntax near the keyword 'where'. ...

In my sas program i only want data down from my mainframe server where date=20150427

sas,where
I want to ask my mainframe server if i only could get the data from the date=20150427. Like a where statement in SQL So problem is that the data is "flat" data so i have defined each column with a input statement i tried to use where=(L7DANDAT=20150427) L7DANDAT is the...

WHERE over a varchar field with multiple Id's

sql,sql-server,where,varchar
I need make a query on SQL Server 2005 to match this scenario, I have a varchar(max) field with some id's like: "12323,12345,123,434345,2324,1211212" and the user will give me a group, the first 3 numbers; So, in where clause I'll have to match each of this id separate by a...

Must declare the scalar varialble

mysql,sql,select,parameters,where
I am using this simple code to pivot some column. But I can't make it work due to that error. DECLARE @IO_dy AS VARCHAR(100) = '>9C604-M' DECLARE @style_dy AS VARCHAR (100) = 'S1415MBS06' DECLARE @query AS VARCHAR(8000) DECLARE @con AS VARCHAR(8000) SET @con = STUFF((SELECT distinct ',' + QUOTENAME(Size_id) FROM...

Setcontent / Selecting on dates

twig,where,bolt-cms
Bolt's docs say what you can use several ‘shortcuts’ for selecting records with dates in the past or future. And "Internally, Bolt uses the strtotime() funtion for this, so we refer to its manual page for details." So, i trying use date_modify() in setcontent = 'something' where {} but...

How to vary the WHERE clause of a linq to entity statement?

vb.net,linq,entity-framework,where
I am using entity framework 6.1.2 with Visual Studio 2012. Right now I have code to this effect, where min, max and item.value are doubles: If Not Double.IsNegativeInfinity(min) AndAlso Not Double.IsPositiveInfinity(max) Then query = From item In query Where item.value >= min AndAlso item.value <= max select item ElseIf Not...

MySql AVG() and WHERE

php,mysql,where,average
I'm struggling on how to write this query and cant quite find an answer to help me with my case. Consider the following table: ----------------------------------------------- | ID | Value1 | Value2 | Value3 | Date | ----------------------------------------------- | 1 | 10 | 23 | 30 | 2015-01-01 | ----------------------------------------------- |...

T-SQL. CASE expression in WHERE clause using IN operator

sql,sql-server,tsql,case,where
If user put 800 as @WorkShop It should return all records having 800 workshop Id and 900 workshop id. If user pass any other Id as @WorkShop It should return only records for choosen @WorkShop Id. I have tried in following: SELECT * FROM Test WHERE Workshop IN ( CASE...

MySQL select sum then two grouping

php,mysql,sum,where,having
I have a table with id, name, type, price, name, date and type_2. Theses are bills. What do I have to query if I want to select all the bills between First May and 6 june that are to Mr. X. My code so far: SELECT sum(prix) from notes_de_frais WHERE...

Two “where” statements with one table doesn't work without subqueries

sql,sql-server,sql-server-2008,tsql,where
I've got a table with 3 columns: name, lastname and date. For example: Name Lastname Date Ab Ab 2008-07-01 Ab Ab 2006-06-23 Kb Kb 2008-07-01 Kb Kb 2007-06-03 I need to find the names of those who are assigned to 2008-07 and not to 2006-06. So for this example the...

Rails Active Record .where statement optimization

ruby-on-rails,rails-activerecord,where
I'm building an ecommerce site and want to use an active record where statement to find shipments that are scoped to a certain supplier and certain shipment states. Here's what I have now: Spree::Shipment.where("stock_location_id = ? and "state = ?", spree_current_user.supplier.stock_locations.first.stock_location_id, 'shipped' || 'ready') I've found that this results in...

Multiple joins with ordered by count ignores where conditions

mysql,count,where
I am trying to only get rows from video_index that belongs to a specific category from category_video_rel and order the result by COUNT of view count. This is the query I'm using: SELECT COUNT(DISTINCT view_count.id) AS count, view_count.remove, view_count.video_id, video_index.id AS video_id, video_index.active, video_index.remove, video_index.title AS title, video_index.date_published AS date_published,...

Oracle SQL Left and right outer Join with/Without where clause giving different outputs

oracle,join,where
Why is there a difference in output for the below queries? As per my understanding it should give the same output for the first 3 queries and same output for the last 3 queries. select count(*) from CTM_People a left outer join user_x b on a.remedy_login_id = b.login_name; Result 1:...

Query “where” with ruby on rails

ruby-on-rails,ruby,where
I've in my app, posts as ideas, and these ideas belongs to an activity and a status. And I want to sort them by activity for one status so I did in my controller @idees_en_place = Idee.where(statut_id= "2") @activites = Activite.all And in my view : <% @activites.each do |activite|...

Windows App c# SQLlite Database Query

c#,sql,windows-store-apps,where
Really new to SQL and I have spent days trying to do queries in my windows store app but can not get the where clause to work I use the following code to query my database string query = string.Empty; public async Task<List<CityClass>> GetListCities(int fred) { List<CityClass> objLstCoty = new...

Fast where() function in C++

c++,where
I have an integer array filled with 0s and 1s. I am looking for the fastest way in C/C++ to get the positions (indices) of the 1s, something similar to the where() function in numpy. Edit 1: since I only store bits, a char array would do the job just...

Simplify Powershell Where-Object

powershell,csv,where
I have working import-csv statement that uses where-object Import-Csv D:\Script\my.csv | Where-Object {$_.SourceIP -like '10.251.22.11*' -or $_.SourceIP -like '10.251.22.*' -or $_.DestinationIP -like '10.251.22.11*' -or $_.DestinationIP -like '10.251.22.*'} If I try to simplify the statement, it doesn't work Import-Csv D:\Script\my.csv | Where-Object {($_.SourceIP -like ('10.251.22.11*' -or '10.251.22.*')) -or ($_.DestinationIP -like ('10.251.22.11*'...

How can I convert a list to a numpy array for filtering elements?

python,arrays,numpy,where
I have a list of float numbers and I would like to convert it to numpy array so I can use numpy.where() to get indices of elements that are bigger than 0.0 (not zero) I tried this, but with no luck: import numpy as np arr = np.asarray(enumerate(grade_list)) g_indices =...

Using Where and Count on two tables

mysql,table,count,where
I have two tables Foods ---------- ID Name ---------- 1. Chips 2. Pizza 3. Fish 4. Pasta People ----------------- ID Name FoodID ----------------- 1. Robert 3 2. Norman 2 3. Leonard 4 4. Huey 3 What I'm supposed to do is retrieve any food that belongs to more than one...

Android sqlite Where clause returning one row column with id

android,sqlite,where
I want to get a single column of a row with an id , shall I do String selQ = "SELECT " + name + " FROM " + table+ " WHERE " + id+ " = '" + id + "'"; or String selQ = "SELECT * FROM "...

Laravel Eloquent where and or between in one query

laravel,eloquent,where
Hello what is the Laravel eloquent code for this: SELECT * FROM dtrs inner join emp_informations on dtrs.enrollnum = emp_informations.enrollnum where (emp_informations.EmpID = '07081408') and (date_in between '2015-03-05' and '2015-03-20' and date_out between '2015-03-05' and '2015-03-20') ORDER BY dtrs . date_in DESC Here's my code in eloquent, and it doesn't...

MySQL Case Sensitive Search Binary or Collate

mysql,binary,where,collate
I need to do a case sensitive search on a field in my database. I see some people suggesting the Binary approach. SELECT * FROM car WHERE BINARY brand = 'Toyota' Others are using the Collate approach SELECT * FROM car WHERE brand COLLATE latin1_general_cs = 'Toyota' I'm not sure...

Neo4J/Cypher: is it possibile to filter the length of a path in the where clause?

path,neo4j,cypher,where
Let's suppose we have this simple pattern: p=(a)-[r]-(b) where nodes a and b have their own properties already set in the WHERE clause (e.g. a:Movie AND a.title = "The Matrix" AND b:Movie). I'd like to add another condition in the WHERE clause like LEGHT(p) =2 OR LENGTH(p)>6 (not the correct...

Reuse field values in WHERE clause

tsql,where,sql-server-2014
How do I optimize the performance of the following T-SQL so heavyFunctionCall function will get called just once. Looking for the fastest option among table variables, temp tables, CTEsor something else? SQL: select dbo.heavyFunctionCall(a, b, c) from T where dbo.heavyFunctionCall(a, b, c) > 10 ...

MySQL implode subquery result and use in WHERE IN

mysql,subquery,where,implode
SELECT name FROM users WHERE id IN ((SELECT manager FROM users_info WHERE id_user = 1)) Here subquery in WHERE IN () is returning one column and row in this format e.g. 12,13 (imploded array if IDs) But whole SELECT returns only first name with id = 12. It should return...

How to compare multiple table columns with multiple values?

mysql,performance,select,where
I have a table with N columns like this column 1 | column 2 | column 3 | ...column N I have n values like this value 1 , value 2 , value 3 , ...value n I wanted to compare these n values with my table's N columns. One...

SQL Server - Function call in WHERE condition

sql,sql-server,where
I've a question regarding making a function call in WHERE condition of a SELECT statement in my stored procedure. Here is my sample query that mimics my original. I've 3 million records in the production database for primary table CDP. My concern is if there would be any performance impact...

Using SELECT SUM WHERE in PHP/MySQL [closed]

php,mysql,select,sum,where
I am learning PHP with MySQL and trying to use SELECT SUM to give me a total from column 'QuantityChecked', but only WHERE the 'Lot' matches and then display it. In this case I have provided some of the code I am using, please let me know if I further...

Mysql query check the blob column type in where clause

mysql,sql,blob,where
I found out that CONVERT(object USING utf8) is for converting blob to text, but it doesn't seem efficient in the where clause, like this: Select * from Page where CONVERT(Page.page_title USING utf8) = 'AccessibleComputing' Is this the only way and the correct way? because it is taking too much time....

Mention more than one coloumn in where cause

sql,where,like
I want to do search in my app. Here is a general look of my query SELECT * FROM My_Table WHERE Col1 OR col or Col3 LIKE "String"; My question is what is the correct syntax for that query. Thanks....

find the part of the where clause that cause return in sql

mysql,sql,where
I have a mysql query that is like so, SELECT USER FROM users WHERE user_name = someUserName OR location = someLocation OR deleted = 1 LIMIT 1 I am trying to figure out which one of the where cases caused a user to be selected. Is this possible to do?...

Dynamicaly build linq to objects where expression

c#,linq,where
Experts! Got stuck with one (might be simple for someone) question. I have an object: public class DataItem { public string Title { get; set; } public string ID { get; set; } public Dictionary<String, Object> Values { get; set; } } What i need to do is to build...

Error in query (1054): Unknown column 'TableValue' in 'where clause'

mysql,sql,join,subquery,where
Following up with SELECTing the contents of the Table, which is a result of another value, I wanna keep a condition here on the generated field. If I execute this query: SELECT *, ( SELECT `TableName` FROM `TableNames` WHERE `TableID`=`IndexType` ) AS `IndexTypeName`, CASE WHEN `IndexType`=1 THEN ( SELECT `Username`...

PHP Extracting a certain part of JSON string where username equals

php,json,string,where
I was wondering how to extract only a certain part from a JSON String: [ { "ID": "132", "countrycode": "DE", "USERNAME": "CRC Titan2000", "Nickname": "^7[6S] ^1Titan", "Money": "550111", "Distance": "105692714", "Trip": "370839", "Bonus": "223", "Last Car": "RB4", "Last Position": "The Hills", "Server": "^7One" }, { "ID": "1634", "countrycode": "ES", "USERNAME":...

SQL WHERE != clause results in no results when the WHERE returns nothing

sql-server,sql-server-2008,select,where
I have this SQL query: USE thr_clinic GO WITH CompleteSchedule AS ( SELECT U.ID as UserID, U.Role, U.Surname, U.Clinic, TS.ID as TimeSlotID, TS.TimeSlot FROM Users U CROSS JOIN TimeSlots TS ) SELECT CS.* FROM CompleteSchedule CS LEFT JOIN Appointments A ON A.MedicalStaffID = CS.UserID AND A.TimeSlot = CS.TimeSlotID AND A.AppDate...

Order result with LIKE operator

sql,sql-server,where,like
In SQL Server, I can use this SQL statement: SELECT * FROM Customers WHERE Country LIKE '%land%'; This query will return values that contains string land. Is it possible to sort returned values by position of string land? Example: Input values : "New Zealand, USA, Landcountry, Alandia" Output values :...

SQL statement where clause by age group

mysql,select,where
I was having some problem when trying to get the age based on each age group using SQL statement. My account table I stored the age as birthDate in this table. Then I am running this SQL statement to get the age: SELECT count(be.eventID) ,TIMESTAMPDIFF(YEAR, str_to_date(a.birthDate,'%d/%m/%Y'), CURDATE()) AS age, a.gender,...

Select columns from Two Tables along with 'Like' statement

c#,sql,sql-server,where
I'm writing a Search Functionality for my website and I need to scan two tables and select rows which contain a specific string that I send (using LIKE). I wrote this but it doesn't send back anything. SqlCommand cmd = new SqlCommand("Select * From Table1, Table2 where Name LIKE '"...

Compare property of model in the list with the constant value

entity-framework,where
Its a simple question but I am starting with EF and dont know: I have two classes (db objects): Company (simplified) public class Company { public int ID { get; set; } public string Name { get; set; } public virtual ICollection<UserGroup> UserGroups { get; set; } } and userGroup...