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....
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,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...
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...
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...
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 +...
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 ...
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:...
Use the having clause .. it applies to groupings. (Similar to where) so after the group put having sum(players.points)>300...
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 =...
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...
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...
Just update your $where condition $where = array('MONTH(c.cashDate)' => 'MONTH(NOW())'); into $where = 'MONTH(c.cashDate) = MONTH(NOW())'; ...
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...
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) ...
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...
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...
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...
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...
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...
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....
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 ...
@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 #...
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...
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...
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...
@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...
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...
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...
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...
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-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 ...
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);...
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`; ...
The correct syntax looks like: SELECT * FROM My_Table WHERE Col1 LIKE "%String%" OR col LIKE "%String%" or Col3 LIKE "%String%"; ...
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...
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]) ...
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...
LIKE operator doesn't accept NULLs. Please check a.remedy_login_id
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)) ...
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-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...
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...
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 ...
sql,database,sql-server-2008-r2,where
WHERE MT.Media = 'Telephone' AND LEN('0557500007')>8 and RIGHT(rtrim([MediaValue]),8) =RIGHT('0557500007',8) ...
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); ...
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) ...
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 >...
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,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...
c#,select,collections,lambda,where
change 2nd Where method to Any RoomCollection = LocationalLinkList.Where(o => o.RoomCollection.Any(i => i.Room == obj)); ...
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...
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(); ...
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....
use FIND_IN_SET () SELECT `name` FROM `users` WHERE FIND_IN_SET (`id`,( SELECT `manager` FROM `users_info` WHERE `id_user`='1' )) >0; ...
You can use CHARINDEX SELECT * FROM Customers WHERE Country LIKE '%land%' order by charindex('land', Country) ...
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...
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); ...
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...
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...
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!...
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() ...
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.
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 ...
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...
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...
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)...
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...
just add a NOT condition in front of where clause: SELECT A,B FROM table_name WHERE NOT (A = 'EF' AND B = 'RUI') ...
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 =...
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...
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`...
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%' ...
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 ...
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...
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...
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...
I tried this and it worked: Select * from Page where Page.page_title = 'AccessibleComputing' I think after all it doesn't need any conversion....
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 ...
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....
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...
If you use utf8 characters binnary is best way to get case sensitive search.
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"....
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.
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); ...
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...
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 ...