where-clause

pagination doesnt link to where clause when new page clicked

核能气质少年 提交于 2019-12-04 06:50:00
问题 i have a where clause that shows all categorys where the id=the input value from the previouse page. the pagination works giving me the right amount of pages and the where clause gives me the correct records. when i click on a page nuber however the records shown on the page are not the next set of required records but all records the link to to each page doesnt identfy the whereclause <?php include ('dbconnect.php'); $db = dbConnect(); // function defined in dbconnect.php echo $filmCategory

Return results of query based on todays date in SQL (MySQL)

北战南征 提交于 2019-12-04 05:05:26
问题 I have a query which I got help with but I am stuck on another bit. The code I have is SELECT a.name, COUNT(*) AS num FROM table2 b INNER JOIN table1 a ON b.status_id=a.id GROUP BY status_id What I would like to do now is only show the results if they have been entered on the current date? The date column is in table2. The format for the date column is date and time (eg 1341241153) which is automatically set by the CRM in this way. I am not sure what format this is in! I only need to check if

SQL Server 2005: Call a stored procedure from a WHERE clause

∥☆過路亽.° 提交于 2019-12-04 04:53:59
问题 I need to make a SELECT with a call of a stored procedure in the WHERE clause. It should be something like that.... SELECT distinct top 10 i.x, d.droit FROM v_droit d, v_info i WHERE d.nomdroit='yy' AND i.id<>2 AND (select val from (exec up_droits(i.x, d.droit)) <>3 But it does not work... Any idea? Don't say to replace the stored procedure with a function because is not possible to use the existing code in a function. So the function is not a valid option. I really need to be able to use a

How to improve performance of non-deterministic function of a column in a where clause or join?

左心房为你撑大大i 提交于 2019-12-04 03:32:59
问题 I would like to improve the performance of a query, which does has a where clause with a non-deterministic function call. Select Count(*) From table1 Where DateDiff(month, Cast(table1.Date As DateTime), GetDate()) = 0 I think the question is equally valid for Joins: Select table1.column1 From table1 Inner Join table2 On table1.MonthOfHappyness = DateDiff(month, Cast(table2.SomeDate As DateTime), GetDate()) Since DateDiff(month, Cast(adrPkt.PktRevDato As DateTime), GetDate()) is non

how to add WHERE clause to Query on android

≡放荡痞女 提交于 2019-12-04 02:27:30
I would like to limit the results to those whose KEY_HOMEID is equal to journalId. I've been on this for a couple days any help would be appreciated. public Cursor fetchAllNotes(String journalId) { return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_HEIGHT, KEY_BODY, KEY_HOMEID},"FROM DATABASE_TABLE WHERE KEY_HOMEID = journalId",null, null, null, null,null); } Have a look at http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#query Your query should look a little like this: mDb.query(DATABASE_TABLE, // Table name columnNames, // String[] containing your

Haskell - defining a function with guards inside a 'where'

拜拜、爱过 提交于 2019-12-03 23:20:31
I'm just starting out at teaching myself Haskell. This code is supposed to do prime factorisation: divides :: Integer -> Integer -> Bool divides small big = (big `mod` small == 0) lowestDivisor :: Integer -> Integer lowestDivisor n = lowestDivisorHelper 2 n where lowestDivisorHelper m n | (m `divides` n) = m -- these should belong to lowestDivisorHelper | otherwise = lowestDivisorHelper (m+1) n primeFactors :: Integer -> [Integer] primeFactors 1 = [] primeFactors n | n < 1 = error "Must be positive" | otherwise = let m = lowestDivisor n in m:primeFactors (n/m) I get a parse error on the

MYSQL use 'LIKE' in 'WHERE' clause to search in subquery

筅森魡賤 提交于 2019-12-03 23:16:19
How would you use 'LIKE' to search in a subquery? E.g. i've tried doing this, but doesn't work: SELECT * FROM mytable WHERE name LIKE '% (SELECT name FROM myothertable) %' I have this so far: SELECT * FROM t1 WHERE t1.name IN (SELECT t2.name FROM t2) AND (t1.title IN (SELECT t2.title FROM t2) OR t1.surname IN (SELECT t2.surname FROM t2)) It's working ok as it returns exact matchs, but it doesn't seem to return my other records that are similar, so I would like to also check that: t1.title LIKE '%t2.title%' AND t1.surname LIKE '%t2.surname%' How would i do this? Using a JOIN: SELECT a.* FROM

How to compare Timestamp in where clause

岁酱吖の 提交于 2019-12-03 16:16:58
I have a table with timestamp column i want to get the values where the timestamp in specific month (for example where the timpestamp between 1 september and 30 septemper) taking in considration if the month is 31 day. I use this query: SELECT users.username, users.id, count(tahminler.tahmin)as tahmins_no FROM users LEFT JOIN tahminler ON users.id = tahminler.user_id GROUP BY users.id having count(tahminler.tahmin) > 0 Can i add where timestamp IN(dates_array) ?? date_array will be the dates of the whole month?? SELECT users.username, users.id, count(tahminler.tahmin)as tahmins_no FROM users

Haskell where clause syntax inside a do block

感情迁移 提交于 2019-12-03 16:08:42
问题 I am trying to refactor a mapM_ function call inside a do block in Haskell. I would like to extract the lambda to a (locally) named function to make the code more readable. My code originally looks like this: do -- ... mapM_ (\x -> x + 1) aList return aValue I would like to change it to do -- ... mapM_ func aList where func x = x + 1 return aValue but I am getting a syntax error on the return aValue line. My actual lambda is more complicated :-), but I did try it with this same lambda to make

Getting the last record in SQL in WHERE condition

删除回忆录丶 提交于 2019-12-03 13:31:31
i have loanTable that contain two field loan_id and status loan_id status ============== 1 0 2 9 1 6 5 3 4 5 1 4 <-- How do I select this?? 4 6 In this Situation i need to show the last Status of loan_id 1 i.e is status 4. Can please help me in this query. Since the 'last' row for ID 1 is neither the minimum nor the maximum, you are living in a state of mild confusion. Rows in a table have no order. So, you should be providing another column, possibly the date/time when each row is inserted, to provide the sequencing of the data. Another option could be a separate, automatically incremented