clause

Variable LIMIT Clause in MySQL

I am writing a stored procedure where I have an input parameter called my_size that is an int, I want to be able to use in a limit clause in a select statement. Apparently this is not supported, is there a way to work around this? # I want something like: SELECT * FROM some_table LIMIT my_size; # Instead of hardcoding a permanent limit...

How to do a WHERE...IN... clause in LinqToSql?

Bear with me, I'm beginning: How can I select multiple elements using a WHERE...IN... type of clause as in select * from orders where orderid in (1, 4, 5) in LinqToSql? I'd prefer not to have a lambda expression since they scare me. Thanks in advance! ...

LINQ where Clause doubt

I have tried one where clause in Linq to get details about Users those who are Active and AllowLogin is also true. So how can I compare the table values (both are boolean values) with true or false? ...

Dynamic where clause in sqlahcmey

Hello I am trying to make the where clause in sqlalchemy for where condition like a==b and id in(1,2,3,4,5) and (x==y or t==y) i get input as [['a==b'], 'and', [<object of sqlalchemmy binary expression>], 'and', '(', ['x==y'], 'or', ['t==y'], ')'] Now from this list input i want to make the where expression. I tried making all...

Code With "No Guarantee"/"No Liability" Clause

I've seen code from time to time that has a clause in the license or at the top of the code that mentions that the author is not liable and does not guarantee that the code is fit for production, or something to that effect. I'm no expert in legality and licensing, I'm just wondering why this is done. Have there actually been cases wher...

MySQL where clause and ordering by avg() as a sub query

Although I can group and order by on an aliased sub query, I can't use the alias in a where clause. Do I need to use a join instead? Works: SELECT entries.*, (SELECT avg(value) FROM `ratings` WHERE ratings.entry_id = entries.id) as avg_rating FROM `entries` ORDER BY avg_rating DESC Fails ("unknown column 'avg_rating' i...

Oracle date function

Hi, I am executing the below query,It returns me the blank row.However there are records in the table having upd_time = '12-MAR-08'.I don't understand why it is not returning the date '12-MAR-08'.Please help me out?? SELECT br_data.upd_time FROM BANKREC.br_data where br_data.upd_time = '12-MAR-08'; ...

Where clause variable for linqtosql from IDs in Stored Procedures.

Hi, I have created a function that retrieves values based on datepart of a datefield from a stored procedure: public List<spDB1GetIDsByTimeResult> GetIDsByTime(int timePart) { using (DB1DataContext db1= new DB1DataContext ()) { List<spDB1GetIDsByTimeResult> query = db1.spDBGetIDsByTime(timePart).ToList()...

Zend framework SQL select query construction (ORDER BY)

I have a database with VARCHAR column url. I would like to fetch rows so that the ones that have any url value have priority over other rows, but are ordered by date row (descending), so ORDER BY 'url' DESC, 'date' DESC wouldn't work as it would order them alphabetically first. Basically, it would look something like this: Table: ID ...

Oracle OCI: Problem in Query with Date field

Client compiled with OCI: 10.2.0.4.0 Server: Oracle9i Enterprise Edition Release 9.2.0.4.0 The problematic query is: SELECT CODIGO FROM LOG WHERE TEL = :telnumber AND DATE_PROC = '05-JUL-08' Table description: SQL>describe LOG; TEL NOT NULL VARCHAR2(15) CODIGO NOT NULL VARCHAR2(20) DATE_PROC NOT NULL DATE As simple as it might loo...

How to Optimize the Use of the "OR" Clause When Used with Parameters (SQL Server 2008)

I wonder if there is any wise way to rewrite the following query so that the indexes on columns get used by optimizer? Create Procedure select_Proc1 @Key1 int=0, @Key2 int=0 As BEGIN Select key3 From Or_Table Where (@key1 =0 OR Key1 =@Key1) AND (@key2 =0 OR Key2 =@Key2) END GO Even though columns in the W...

Separate clauses of an if statement?

Is there any way to have multiple clauses in an if() statement? For instance: if( ($username=='textUser' && $role=='admin') || ($admin=='yes')) { // If the username AND role are set to admin OR if the admin is set to 'yes' } else { // Neither clauses of the if statement are true } Perhaps this is actually the correct code, i ...

Prolog: How to produce a multiple answer output?

Given: fruitid('Apple', 'Granny Smith', 1). How would I go about creating the clause: print_fruit_details(FruitID) :- Which would output 'Apple' and 'Granny Smith' given the input 1. Thanks, JAS ...

mysql php query HAVING clause

Hi! Im trying to get this query to work but i get this error: Unknown column 'zips.city' in 'having clause' `$query = "SELECT zips.* FROM zips HAVING zips.city LIKE '%$city%' AND zips.stateabbr LIKE '%$state%' LIMIT 1"; $result = mysql_query($query) or die (mysql_error());` my zips table has a...

Prolog - Declaring arithmetic clauses

A simple question, how would I go about declaring a clause which would produce the number specified +1 +2 and +3? I have tried: addup(Thenumber,Thenumber+1). addup(Thenumber,Thenumber+2). addup(Thenumber,Thenumber+3). but when I run it with say, Thenumber=5, it just returns 5+1 5+2 5+3. I have tried using 'is' to force it to evaluate ...

PHP text output in clauses

Hello. I am working on a PHP project. There, I often use following syntax to output text in a cluase: if($boolean){ ?> output text <? }else{ ?> alternative <? } On my computer, this works perfectly well. I use XAMPP foer Mac OS X. But when I send the files to my coworker, these outputs often do not work and the compiler complains ...

Oracle SQL clause evaluation order

In Oracle, which clause types get evaluated first? If I had the following ( pretend .... represent valid expressions and relation names ), what would the order of evaluation be? SELECT ... FROM ..... WHERE ........ GROUP BY ........... HAVING ............. ORDER BY ................ I am under the impression that the SELECT ...

Linq where clause problem

I thought I'd seen somewhere a while back an example of where clause which called a function that gave a bool result ,and I can't find it again so I'll outline my problem. I have a collection Dictionary< string, KeyValuePair < int, int >> in which I want to have a query for the string key. On the surface that is simple but unfo...

Selecting table using case clause in from clause

I have 8 table that contain different specific value for computer peripheral they are glpi_device_ram, glpi_device_hdd, glpi_device_gfxcard, glpi_device_sndcard. Each table has the same designation column in each table that contain device name. i have table glpi_computer_device that contain FK_device that contain id for each 8 table abov...