Dear friends,
see the Following query ----- -
SELECT headline, Concat(EXTRACT(YEAR FROM datetime),'-',EXTRACT(MONTH FROM datetime),'-',DAYOFMONTH(datetime)) as abc FROM news_news where catid='1' and abc>='2007-10-1' and abc<='2007-10-30'
here abc is a temp variable can i use it in where clause in same query ?????
here i excute this but it give
#1054 - Unknown column 'abc' in 'where clause'
plz tell me anyone is it possible or not ????
2 3096 pbmods 5,821
Recognized Expert Expert
Heya, Sanjay.
Please use CODE tags when posting source code:
[CODE=mysql]
MySQL code goes here.
[/CODE]
You can create MySQL variables using the SET keyword: bartonc 6,596
Recognized Expert Expert
Dear friends,
see the Following query ----- -
SELECT headline, Concat(EXTRACT(YEAR FROM datetime),'-',EXTRACT(MONTH FROM datetime),'-',DAYOFMONTH(datetime)) as abc FROM news_news where catid='1' and abc>='2007-10-1' and abc<='2007-10-30'
here abc is a temp variable can i use it in where clause in same query ?????
here i excute this but it give
#1054 - Unknown column 'abc' in 'where clause'
plz tell me anyone is it possible or not ????
In MySQL, names of temporary variable are not known at the time that the where clause is being parsed. Hence; that will not work. But this works fine (I have a column named "timestamp" which is a DATETIME type): - SELECT * FROM stations
-
where `timestamp` between '2007-02-01' and '2007-02-13';
For the desired dates: '2007-02-01' and '2007-02-12'
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Peter Jenny |
last post by:
Hi NG
How do I have to use a VARCHAR2 variable in a where clause.
I could not find an example.
PART_NR VARCHAR2(20);
myPartId NUMBER()20;
PART_NR := '101 189';
select part_id into myPartId from part where part_nr = PART_NR; -- not working, hwo to do ?
|
by: Edward |
last post by:
ASP.NET / VB.NET
SQL Server 7.0
Our client has insisted that we change our established practice of
building SQL in-line and move it all to SPROCs. Not a problem for 80%
of the app. However, we have a number of Search/Filter forms that
contain a number of controls to allow more or less focused search
criteria to be built up.
I have a class that does this quite nicely, examining all controls for
|
by: Colleyville Alan |
last post by:
I have built a SQL statement that is trying to loop through the fields of a
table that was built from a spreadsheet and hence is "short and fat". So
rather than hard-coding, I have a loop from field #6 to the last field
(#63). When I use the fld variable (type integer) in the loop, I have no
problem with this line which is near the end of the SQL statement:
strMySql = strMySql & "Accts., Accts.Manager, " & ","
But when I try to...
|
by: Richard Hollenbeck |
last post by:
Help! I don't know why this isn't working:
Private Sub Combo9_Change()
Dim UsersCourseSelection As String
UsersCourseSelection = Me("Combo9").Value
Combo13.Visible = True
'the following SQL thing is all on one line in the actual code.
|
by: Justin |
last post by:
I have a variable string "myvar" and I need to pass it to the WHERE clause of
a SELCET statement I have tried myvar.ToString(), Cint, parse and convert.
The Select statement works fine when I pass a value manually eg WHERE mycust
= "50".
Any ideas?
Thanks, Justin.
| |
by: Jerry |
last post by:
I am a MySQL and PHP newbie. I am having trouble getting the $w variable in
my code below passed to mysql. When I use the value of $w directly in the
Where clause, the correct rows are returned. However, when I try to use the
variable in the Where clause, either an error occurs or no rows are
returned. Any thoughts greatly appreciated!
I am using php-4.4.2 and MySQL-4.1.18-0 on Suse 9.1
Jerry
|
by: MCOOP |
last post by:
Is there a way to have a declare variable (@where) be used as the WHERE clause in a stored procedure?
The reason I ask is that I'm trying to use one sql statement for several
possible WHERE conditions. The WHERE could be looking for Lastname or an account number.
example:
create procedure selCustomerSearch @Acct int = null
, @Lname varchar(20) = null
AS
|
by: dancer |
last post by:
I get this compilation error:
Handles clause requires a WithEvents variable
I know I need to declare a WithEvents variable, but I don't know how or
where.
Here is a part of the code:
<%@ Page Language="VB" debug="true" %>
|
by: Joey |
last post by:
I am querying a DataSet with LINQ. I am running into a problem when
trying to construct my query because in the "from" clause I do not
know the table name (range variable) until runtime. Possible table
names might include "SomeTable1" or "SomeTable236" etc...
Unfortunately when I try to use something like "from SomeTable +
MyChangingNumber.ToString() in..." in my from clause it does not work.
How can I set this up to use a range variable...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |