Menu
  • HOME
  • TAGS

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

mysql,select,count,where

select a.flipbook, count(*) from visits a inner join pages p on a.id = p.visit_id group by a.flipbook There are no need for subqueries - this is just a basic join and aggregate....

C# predicate list passed to linq Where clause

c#,linq,where,predicate

You have to loop over your filters and run a test on each one. You can do it with linq like this to return true if any of your filters are true: .Where(p => { foreach(f in filters) if (f(p) == true) return(true); return(false)}) or like this to to return...

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

mysql,sql,where,multiple-select

Not recommended: programmatically generate a massive query: SELECT count(*) FROM request WHERE '2013-04-10' BETWEEN open_date AND close_date OR '2013-05-10' BETWEEN open_date AND close_date OR .... '2015-11-4' BETWEEN open_date AND close_date Note: this gives you a total. If you want a total for each date, you need to do it the...

Linq statement with 2 joins a where and need a count

c#,linq,join,count,where

It seems to me like you don't need a projection at all here 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...

MS Access WhereConditions in xml export

sql,xml,ms-access,report,where

Im allready found answer. Create your own Report with filter, make export and at end just save moves (I dont know how it is in Eng lang). Than make makro DoCmd.RunSavedImportExport "NAME-saved" Thats all :) ...

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

mysql,sql,where

Sometime I'm debugging something and I'd like to be able to answer the same kinds of questions. Obviously you can comment out parts of the query and run it that way. If you're not sure about an expression or nulls or you just want to confirm your sanity then you...

Windows App c# SQLlite Database Query

c#,sql,windows-store-apps,where

Looking at how you would add that WHERE clause to the end of your query, it wouldn't even compile as the = sign is outside of the string you're building up. Try doing the following: query = "Select " + DBColumns.Id + "," + DBColumns.WORKNUM + "," + DBColumns.FAULTREF +...

SQL Server Insert with where clause

sql,sql-server,where

Use insert to insert new data into your table. But you rather want to update your exsiting data. Use update for this update Table1 set code = 'ss23' Where sequence between 0 and 999 ...

How to compare multiple table columns with multiple values?

mysql,performance,select,where

In your case no. i would suggest to change structure of the database if it's possible: table id | column | value_of_column | date example: 1 | column_1 | zzz 2 | colums_2 | yyyy 3 | colums_1 | yyyy 4 | colums_5 | yyyy .... and then your query:...

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

mysql,sum,where

Use the having clause .. it applies to groupings. (Similar to where) so after the group put having sum(players.points)>300...

Combining two select statements

sql,database,select,where

Try to this 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 = c.SERVICEREQNO, ChangeId =...

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

mysql,if-statement,where

Try: UPDATE practice1 p1, practice2 p2 SET p1.`Price` = p2.`COL3`, p1.`Purchaser` = p2.`COL2` WHERE p1.`Hip` = p2.`COL1` ; Demo: http://sqlfiddle.com/#!9/b3a26/1...

Must declare the scalar varialble

mysql,sql,select,parameters,where

addition to another answer just single quotes to the variable names used in the query 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 iPLEXSTY_SIQ FOR XML PATH(''), TYPE...

Where by month in codeigniter

codeigniter,where

Just update your $where condition $where = array('MONTH(c.cashDate)' => 'MONTH(NOW())'); into $where = 'MONTH(c.cashDate) = MONTH(NOW())'; ...

WHERE over a varchar field with multiple Id's

sql,sql-server,where,varchar

You need a function to split the strings into separate values. Here's one. I don't know who wrote it originally, but it's been in our library since forever: CREATE FUNCTION dbo.split_string (@v_string VARCHAR(2000), @v_delimiter VARCHAR(1)) RETURNS @output TABLE (id INT IDENTITY NOT NULL, item VARCHAR(2000)) BEGIN DECLARE @v_item VARCHAR(2000); WHILE...

Basic SQL Statement (Where)

sql,where

You cannot use AND here. Because subfamily will never have the values 994,948 and 931 at the same time. You should have used OR instead. Or simply using IN (much better way for a list of values): SELECT type, code, gestion, situation FROM products WHERE subfamily IN (994,948,931) ...

Dynamically add like operators in where clause

sql,where,like

You can do this by dynamically creating your sql query: string[] new = searchtext; String query = "select Qid from questions"; Write a for loop in your application that loops through your search array: Pseudo code incoming: For(String searchstring in new){ if(new.indexof(searchstring) === 0){ query += " where qdescriptions like...

SQL Server - Function call in WHERE condition

sql,sql-server,where

Instead you can do this. Assign the function result to a variable and use it in where clause declare @check int, select @check = dbo.testFunction(@UserId) SELECT C.AwardId, C.ProgramName, Count(ClientId) as Intakes FROM CDP C LEFT JOIN UserRoleEntity URE ON C.AwardId = URE.EntityId LEFT JOIN UserRole UR ON URE.UserRoleId = UR.Id...

Using Where and Count on two tables

mysql,table,count,where

You want to join the tables on the common field. The WHERE is serving as an inner join. Then GROUP BY Foods.name aggregate rows by food type. Count is an aggregate operator that always works with the GROUP BY. SELECT Foods.Name, Count(*) FROM Foods, People WHERE Foods.ID = People.Food GROUP...

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

You can't specify any WHERE clause with the INSERT .. VALUES statement. But you can do that with the INSERT .. SELECT statement as shown below. Also... The record with the values 1, 11, 1, and tomorrow does 100% already exist, yet inserts it again. GETDATE() returns a timestamp with...

SQL statement where clause by age group

mysql,select,where

Use Between Operator to filter the result between two values. SELECT Count(be.eventID), Timestampdiff(YEAR, Str_to_date(a.birthDate, '%d/%m/%Y'), Curdate()) AS age, a.gender, be.eventID FROM account a INNER JOIN bookedevent be ON be.bookedEventBy = a.accountName WHERE a.gender = 'M' AND Timestampdiff(YEAR, Str_to_date(a.birthDate, '%d/%m/%Y'), Curdate()) BETWEEN 11 AND 20 -- Here you can define the...

Simplify Powershell Where-Object

powershell,csv,where

Instead of -like, use -match in this case. Import-Csv D:\Script\my.csv | Where-Object {$_.SourceIP -match '^10\.251\.22\.*' -or $_.DestinationIP -match '^10\.251\.22\.*'} Also, 10.251.22.* will match 10.251.22.11*, so you can combine them....

Reuse field values in WHERE clause

tsql,where,sql-server-2014

Doing this would only run your function once on every row instead of twice: SELECT * FROM ( SELECT dbo.heavyFunctionCall(a, b, c) AS x FROM T) a WHERE x > 10 ...

Query “where” with ruby on rails

ruby-on-rails,ruby,where

@idees_en_place = Idee.where(statut_id= "2") There are two problems with this code. First, id is a Integer type (unless you've defined it as String). Second, its a key value you pass to where clause, and you pass these either as :status_id => 2 # old hashrocket syntax or status_id: 2 #...

MySQL WHERE variable

php,mysql,where

Use find_in_set SELECT * FROM table WHERE find_in_set ('11',content) and find_in_set ('22',content) and find_in_set ('33',content) For more information read the documentation...

Select columns from Two Tables along with 'Like' statement

c#,sql,sql-server,where

You have several problems in your code. The first in severity is the fact that you use string concatenation instead of parameters. This makes your code very vulnerable to SQL injection attacks. The second one is that your SQL is simply wrong. You are using an implicit join without any...

OrientDB - LET variable in where

where,orient-db,let

It seems that $category cannot be accessed from the where. I really don't know why. But I solved it using another varaible: SELECT FROM Post LET $category = (SELECT EXPAND(out('PartOf')) FROM $current), $poster = (SELECT EXPAND(in('Posted')) FROM $current), $relatedUser = (SELECT EXPAND(out('IsUser')) FROM (SELECT EXPAND(out('Related')) FROM #18:1) WHERE out('RelatedIn') IN...

Dynamicaly build linq to objects where expression

c#,linq,where

@Silverlay I think what you are looking for is Dynamic LINQ. This is a library provided by the LINQ team itself. What you need to do is use string expressions instead as shown in this blog - http://weblogs.asp.net/scottgu/dynamic-linq-part-1-using-the-linq-dynamic-query-library...

MySql AVG() and WHERE

php,mysql,where,average

Your query is basically fine. Your date constant is not. Dates constants should be enclosed in single quotes: SELECT AVG(PAM_1) FROM MyTable WHERE DATE = '2015-01-01'; If the date could have a time component, then the following is the best way to handle this: SELECT AVG(PAM_1) FROM MyTable WHERE DATE...

Which performs first WHERE clause or JOIN clause

sql,sql-server,select,join,where

The conceptual order of query processing is: 1. FROM 2. WHERE 3. GROUP BY 4. HAVING 5. SELECT 6. ORDER BY But this is just a conceptual order. In fact the engine may decide to rearrange clauses. Here is proof. Lets make 2 tables with 1000000 rows each: CREATE TABLE...

Update values in column across multiple tables using where

sql,sql-server,where

Your second option (generating the scripts) seems like the best one. Now, as for your error. Is your agency code a string? Then that is probably the problem: you need to enclose it in quotation marks. Since you are building a string, they will need to be doubled: select 'update...

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

php,mysql,sql,where

If you're trying to append (concatenate) a new value to the end of an existing row's value you will still need to use UPDATE. It would look something like this: UPDATE iutca_jomcl_adverts SET images = CONCAT_WS('|', images, '$img_name') WHERE title='$title' (CONCAT_WS is "concatenate with separator") However, that won't handle the...

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

sql-server,sql-server-2008,select,where

Since the subquery used in the where clause presumably might return more than one value you probably shouldn't use != but rather not in: AND CS.UserID NOT IN (SELECT StaffID FROM DaysOff WHERE DayOff ...

Laravel Eloquent ORM - Complex where queries

php,database,laravel,orm,where

This would be the query as you had it $result = DB::table('mod_dns_records') ->where('scheduled', 'N') ->where('scheduleTime', 0) ->where('domainId', $id) ->orWhere('deleteRow', 'Y') ->where('domainId', $id) ->get(); However I noticed it can be optimized a bit since the domainId condition exists in both groups: $result = DB::table('mod_dns_records') ->where('domainId', $id) ->where(function($q){ $q->where('scheduled', 'N'); $q->where('scheduleTime', 0);...

MySQL select sum then two grouping

php,mysql,sum,where,having

You may extend your WHERE clause to include other criteria using AND. And if you are going to SUM, you should use GROUP BY. SELECT SUM(prix) from notes_de_frais WHERE `date` BETWEEN '2015-05-01' AND '2015-06-06' AND `name`='Mr. X' AND `type`='plane tickets' GROUP BY `name`; ...

Mention more than one coloumn in where cause

sql,where,like

The correct syntax looks like: SELECT * FROM My_Table WHERE Col1 LIKE "%String%" OR col LIKE "%String%" or Col3 LIKE "%String%"; ...

SELECT DISTINCT user_id of highest value in support_date WHERE

mysql,sql-order-by,max,distinct,where

The WHERE clause in my query is to keep out user_ids where the support_date is inside a range of the past 7 days. You can rephrase it like this: The WHERE clause in my query is to select user_ids where highest support_date is outside a range of the past...

Rails Active Record .where statement optimization

ruby-on-rails,rails-activerecord,where

id = spree_current_user.supplier.stock_locations .first.stock_location_id Spree::Shipment.where(stock_location_id: id, state: %w[shipped ready]) ...

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

sql-server,stored-procedures,where,bit

Try this.. assign @sex with 0,1 or null CREATE TABLE #TEMP(ID INT, SEX BIT) INSERT INTO #TEMP VALUES(1,1) INSERT INTO #TEMP VALUES(2,1) INSERT INTO #TEMP VALUES(3,0) INSERT INTO #TEMP VALUES(4,0) INSERT INTO #TEMP VALUES(5,NULL) DECLARE @sex BIT SET @sex=NULL SELECT * FROM #TEMP WHERE @sex IS NULL or [email protected] DROP...

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

oracle,join,where

LIKE operator doesn't accept NULLs. Please check a.remedy_login_id

Laravel Eloquent where and or between in one query

laravel,eloquent,where

I have changed somethings in your query, please try this : $dtrs=Dtr::Join('emp_informations','dtrs.enrollnum','=','emp_informations.enrolnum') ->where('emp_informations.EmpID','=','07081408') ->whereBetween('dtrs.date_in', array('2015-03-05' , '2015-03-20')) ->whereBetween('dtrs.date_out', array('2015-03-05' , '2015-03-20')) ->orderBy('dtrs.date_in','Desc')->paginate(15); if you have variables, you can make like this: ->whereBetween('dtrs.date_in', array($fromdate , $todate)) ...

Selection of lines from a multiple condition request

php,mysql,sql,select,where

Try this: SELECT p.* FROM proposition p INNER JOIN needs n ON n.idProposition = p.idProposition WHERE idRequirement IN (1, 7, 9) # blah, blah, blah, put your list here GROUP BY p.idProposition HAVING COUNT(idRequirement) = 3 # put the size of the list here What it does: it SELECTs all...

IF in WHERE clause

if-statement,delete,chat,where,messages

Most likely you have run into the problem that the IF() function returns either a string or numeric value. But you seem to expect that it returns a boolean value. (SQL has not boolean data type.) So you have to use an alternative to IF(): SELECT * FROM messages WHERE...

Mysql SELECT with WHERE clause not working with variable

php,mysql,variables,select,where

Since your string has a single quote in it: Store Pickup (Mooresville - Gold's Gym) ...you need to escape the variable $shiploc: $shiploc_escaped = addslashes($shiploc); $sql = "SELECT * FROM cart1_store_locations WHERE pickup_name= '".$shiploc_escaped."'"; Reading up on Zen Cart Escaping Content, it appears this is an option: $sql = "SELECT...

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

sql,sql-server,tsql,case,where

Is this what you want? SELECT * FROM Test WHERE ( @WorkShop = '800' AND Workshop IN('800', '900') ) OR @WorkShop = Workshop ...

right in sql is not working on the where clause

sql,database,sql-server-2008-r2,where

WHERE MT.Media = 'Telephone' AND LEN('0557500007')>8 and RIGHT(rtrim([MediaValue]),8) =RIGHT('0557500007',8) ...

Symfony2 & Dooctrine Where clause using a join

php,symfony2,join,doctrine2,where

It seems that this works, but is it the right approach? $builder = $this->createQueryBuilder("p") ->innerJoin('p.mission', 'm') ->innerJoin('m.game_system', 'gs') ->where("p.published = :published AND gs = :game_system") ->orderBy("p.date_published", "DESC") ->setMaxResults($limit) ->setParameter("published", true) ->setParameter("game_system", $game_system); ...

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

ruby-on-rails,date,ruby-on-rails-4,where

Write this scope in your Statistics model: scope :last_date_stats, ->(dates) { where(date: dates) } Populate a dates array in your StatisticsController and then use the scoped query to get specific data: dates = (0..11).to_a.map { |n| n.months.ago.end_of_month } @last_date_statistics = Statistics.last_date_stats(dates) ...

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

python,arrays,numpy,where

You don't need numpy arrays to filter lists. List comprehensions List comprehensions are a really powerful tool to write readable and short code: grade_list = [1, 2, 3, 4, 4, 5, 4, 3, 1, 6, 0, -1, 6, 3] indices = [index for index, grade in enumerate(grade_list) if grade >...

Combo box Where Clause

c#,sql-server,where

You need to use a LEFT OUTER join here instead of an INNER join string strQry ="SELECT POMain.po_no FROM POMain INNER JOIN Shipping ON POMain.po_no = Shipping.po_no WHERE Shipping.invoice IS NULL"; And you need to add another condition to the WHERE clause at the end: AND POMain.po_no = " +...

MySQL query with less than and ORDER BY DESC

mysql,indexing,sql-order-by,where,where-clause

Your index is used only for filtering on weight. Here are the steps: All the rows with weight < x (WHERE) are found (using any index starting with weight) That set is sorted (ORDER BY height ...) 0 (OFFSET) rows are skipped; 5 (LIMIT) rows are delivered. The potentially costly...

Get collection containing a specific object out of a collection

c#,select,collections,lambda,where

change 2nd Where method to Any RoomCollection = LocationalLinkList.Where(o => o.RoomCollection.Any(i => i.Room == obj)); ...

Having trouble with SQL 'in'

php,mysql,sql,where

Reason: Inner query should return only 1 column if you want to use it with IN. Solution: Remove status from the inner query. Also use single quotes ' around the variable $brandname: $sql = "SELECT brand,name,product_id FROM product_description where brand = '$brandname' and product_id in (SELECT product_id FROM product where...

Compare property of model in the list with the constant value

entity-framework,where

It would be helpful to see your ApplicationUser class, but I suppose it has a navigation property to UserGroup? If it does, you could do it like this: db.Users.Where(u => u.Id == User.Identity.GetUserId()) .SelectMany(u => u.UserGroups) .SelectMany(g => g.Companies) .Distinct(); ...

Find a Portion of a Database in Ruby

ruby,database,ruby-on-rails-3,object,where

Have a try: Obj.where("id > ?", 10) you will find different ways to retrieve data from the database using Active Record from rails guide....

MySQL implode subquery result and use in WHERE IN

mysql,subquery,where,implode

use FIND_IN_SET () SELECT `name` FROM `users` WHERE FIND_IN_SET (`id`,( SELECT `manager` FROM `users_info` WHERE `id_user`='1' )) >0; ...

Using SELECT SUM WHERE in PHP/MySQL [closed]

php,mysql,select,sum,where

You're submitting the form using POST so the values of hidden elements would be in $_POST, not $_GET. $Lot = $_POST['Lot']; ...

Order result with LIKE operator

sql,sql-server,where,like

You can use CHARINDEX SELECT * FROM Customers WHERE Country LIKE '%land%' order by charindex('land', Country) ...

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

php,mysql,where

If there are NULL values in the archived column, then those rows will not satisfy the inequality predicate. (It's the ages old issue of boolean three-valued logic... TRUE, FALSE and NULL.) There's a couple of ways to deal with NULL values, to get those returned. As one option, you could...

Selecting referenced column entries with SQLITE3: Ignored WHERE-clause

sqlite3,where

The WHERE clause is not ignored. All the values in the bild_id column are larger than 9 because they are strings, not numbers. Check how you import the data. To fix the table, execute something like this: UPDATE combo_bild SET bild_id = CAST(bild_id AS INT); ...

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

mysql,where

You can use case like this: SELECT * FROM `MyTasks` WHERE (CASE DAYNAME(NOW()) WHEN 'Monday' THEN `Monday`=1 WHEN 'Tuesday' THEN `Tuesday`=1 WHEN 'Wednesday' THEN `Wednesday`=1 WHEN 'Thursday' THEN `Thursday`=1 WHEN 'Friday' THEN `Friday`=1 END) Apart from that I don't see any way of you accomplishing this, as the column names...

PHP Extracting a certain part of JSON string where username equals

php,json,string,where

You are not using foreach as it should be. Have a look at your JSON, you have an array of objects. So you have to iterate over you array, and check your object values. By the way, in my answer, I use json_decode( ,false) to force result as a multidimensional...

Between in mysql where clause not working

php,mysql,date,where,between

I got the answer. SELECT * FROM `time_track` where DATE_FORMAT(STR_TO_DATE(track_date, '%c/%d/%Y'), '%Y-%m-%d') between '2015-01-01' and '2015-01-21' ...

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

sql,ms-access,where,like

FINALLY !!!!! I Figured It Out! SELECT firstname, lastname, state FROM instructors WHERE state = 'ga' AND lastname LIKE '*son*' Instead of using the %WildCard I inserted *WildCard on both ends and it displayed exactly what I was requesting ! Thanks Everyone For Your Help!...

Result of findBySQL in Yii

php,mysql,yii,where,find-by-sql

It should be $wynik = $model::model()->findAllBySQL('SELECT * FROM uzytkownik WHERE imie=:imie',array(':imie'=>'Jakub')); Know the difference between, findBySql() And findAllBySql() ...

Eloquent orm show ? instead values in where clause

php,mysql,eloquent,where

That's because Laravel uses bindings to insert values into the query to avoid SQL injection. The ?s will be replaced with the actual values when the query is run.

SQL- WHERE and HAVING

sql,where,having

If you really need to use WHERE instead of HAVING SELECT * FROM ( SELECT Sparte , Region , SUM(Umsatz) as S_Umsatz FROM Fakten GROUP BY Sparte , Region ) d WHERE S_Umsatz >= 50000 ...

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

sql,sql-server,sql-server-2008,tsql,where

I think you want a group by and a having clause, because you are looking for multiple rows: select Name, Lastname from MyTable group by Name, LastName having sum(case when YEAR(date) = 2008 AND MONTH(date) = 7 then 1 else 0 end) > 0 and sum(case when YEAR(date) = 2006...

Haskell local function Is not in scope

function,haskell,where,local

The where clause only provides bindings to the equation directly above (or to the left) of it. You can fix this by moving it up, under the first of equation of psum where it is actually used. Other than that, there are various additional misunderstandings that I'm seeing in your...

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

path,neo4j,cypher,where

Yes, that does work in neo4j, exactly as you've specified. Sample data: create (a:Foo)-[:stuff]->(b:Foo)-[:stuff]->(c:Foo); Then this query: MATCH p=(x:Foo)-[:stuff*]->(y:Foo) WHERE length(p)>1 RETURN p; Returns only the 2-step path from a->b->c and not either one-step path (a->b or b->c)...

Android sqlite Where clause returning one row column with id

android,sqlite,where

you can use query() method private Cursor getSingleRow(int id){ Cursor cur = db.query(TABLE, null, "_id= ?", new String[] { "" + id }, null, null, null); if (cur != null) { cur.moveToFirst(); } return cur; } or you can execute row query just like what you have proposed with some...

How to avoid using a subquery

sql,subquery,where

just add a NOT condition in front of where clause: SELECT A,B FROM table_name WHERE NOT (A = 'EF' AND B = 'RUI') ...

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

sql,sql-server-2008,where,not-exists

Maybe you just want to join directly? WITH ins (MedStaffID, PatientID, TimeSlot, AppDate) AS (SELECT 1, 6, 10, DATEADD(day, 1, CAST(GETDATE() AS DATE))) INSERT INTO Appointments (MedStaffID, PatientID, TimeSlot, AppDate) SELECT ins.MedStaffID, ins.PatientID, ins.TimeSlot, ins.AppDate FROM ins JOIN Users Staff ON (Staff.ID = ins.MedStaffID) JOIN Users Patient ON (Patient.ID =...

Use NOT Equal condition in sql?

sql-server,tsql,condition,where

Your query doesn't really make sense. Grouping happens after WHERE clause, so you're basically getting all orders that have ActivityID ==1 (because if activity Id is 1 there it's always not equal to 4). After WHERE clause is applied you end up with following rows: OrderID ActivityID 1 1 2...

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

mysql,sql,join,subquery,where

You can't use the alias name in where clause You need to either use subquery or having clause SELECT *, ( SELECT `TableName` FROM `TableNames` WHERE `TableID`=`IndexType` ) AS `IndexTypeName`, CASE WHEN `IndexType`=1 THEN ( SELECT `Username` FROM `Users` WHERE `IndexRowID`=`UserID` ) WHEN `IndexType`=2 THEN ( SELECT `MessageContent` FROM `Messages`...

Postgres - WHERE clause on whether values contain a certain string

sql,string,postgresql,where

Use the SQL LIKE statement. With that, you use a % as a wildcard. So, your WHERE statement could be something like: WHERE foo LIKE '%bar%' ...

not letting me insert values with a where clause

php,mysql,pdo,where,mariadb

You can't because INSERT statements don't have WHERE clauses. You need to use an UPDATE statement. For more information on these two seperate and different functions, consult: http://dev.mysql.com/doc/en/insert.html http://dev.mysql.com/doc/refman/5.0/en/update.html ...

Setcontent / Selecting on dates

twig,where,bolt-cms

Unfortunately what you want to do is not as straightforward. You cannot modify the shortcuts that way. The "shortcut" tomorrow is only working inside the setcontent, so the part where you try to modify it with a twig filter "tomorrow"|day_modify("+1 day") will not work. You could try the following, but...

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

sas,where

WHERE statement is allowed in the datastep, but only works on a SET statement. You can't use it on an infile-sourced data step. You can either: Use an IF statement in the data step. Use a WHERE statement in PROC DOWNLOAD The former is probably more efficient, but the latter...

Fast where() function in C++

c++,where

If you store only bits, I suppose you could just use bool type, not char. If speed is main issue, you should consider using pointers over [] brackets to get your array elements, because using brackets tells your program to manually search all memory for your array element and pointers...

Mysql query check the blob column type in where clause

mysql,sql,blob,where

I tried this and it worked: Select * from Page where Page.page_title = 'AccessibleComputing' I think after all it doesn't need any conversion....

SQL statement WHERE clause condition with multiple values

mysql,sql,select,where

Use IN clause SELECT count(*) AS totalRaces, a.races FROM bookedevent be INNER JOIN account a ON be.bookedEventBY = a.accountName WHERE be.eventID in(70,69,55) GROUP BY a.races ...

where clause is not narrowing down the records to what i have specified

mysql,sql,count,where,mysql-workbench

You must be having some relation between the two tables. Something like officeId in staff table? select count(*) from staff,office where office.office_id=staff.office_id and office.office_id=10; The first condition is to link the tables and the second one to filter it....

A multiple conditioned count

sql,if-statement,where,business-objects,rich-client-platform

You'll need to use multiple variables to accomplish this. Assuming you're starting out with objects named: | [Qtr] | [Mth] ----|------------ [Ref] | [Val] 1) Create a variable to hold the max month per quarter with a non-zero value: MaxM = Max([Mth]) In ([Ref];[Qtr]) Where ([Val] <>"00") Put this into...

MySQL Case Sensitive Search Binary or Collate

mysql,binary,where,collate

If you use utf8 characters binnary is best way to get case sensitive search.

Laravel where on relationship object

php,laravel,eloquent,where,relationship

The correct syntax to do this on your relations is: Event::whereHas('partecipants', function ($query) { $query->where('IDUser', 1); }])->get(); Read more at http://laravel.com/docs/master/eloquent#eager-loading P.S. It's "participant", not "partecipant"....

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

vb.net,linq,entity-framework,where

Edit I misunderstood the original question of dealing with +/- infinity. Instead of writing three queries you could test the min/max and if either returns infinity then set them equal to Double.MaxValue or Double.MinValue and then execute the query.

MYSQL where clause causes syntax error

mysql,syntax,where,clause

GROUP is a reserved word so it needs to be between back tick `` Also, if $galgroup can be a string and not only a number, you need to add quotes arround it : $stat_qry = mysql_query("SELECT * FROM stats WHERE `group`='$galgroup'") or die("STATS ERROR: ".mysql_error()); $stat = mysql_fetch_array($stat_qry); ...

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

sql,tsql,select,where

You have incorrect syntax: Select * From Clients as c WHERE ISDATE(@birthdaysearch) = 0 OR (ISDATE(@birthdaysearch) = 1 AND c.BirthDay LIKE CONVERT(datetime, @birthdaysearch, 103)) or: Select * From Clients as c WHERE c.BirthDay LIKE CASE WHEN ISDATE(@birthdaysearch) = 0 THEN '%' ELSE CONVERT(datetime, @birthdaysearch, 103) END But it is very...

Multiple joins with ordered by count ignores where conditions

mysql,count,where

Your FROM clause is mixing old style joins and new style joins Instead try: FROM view_count JOIN video_index ON view_count.video_id = video_index.id JOIN category_video_rel ON category_video_rel.video_id = video_index.id ...