Hi
Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order
by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of these?
Donno how to do it :S 6 1742
On 19-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote: Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of these?
select news.User_ID as userid, * from ...
--
Tom Thackrey www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Can you give me an exampl, I cant get it :(
Thanks,
Hayden
"Tom Thackrey" <us***********@nospam.com> wrote in message
news:BZ*******************@newssvr29.news.prodigy. com... On 19-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote:
Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of
these? select news.User_ID as userid, * from ...
-- Tom Thackrey www.creative-light.com tom (at) creative (dash) light (dot) com do NOT send email to ja*********@willglen.net (it's reserved for spammers)
On 20-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote: "Tom Thackrey" <us***********@nospam.com> wrote in message news:BZ*******************@newssvr29.news.prodigy. com... On 19-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote:
Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of
these? select news.User_ID as userid, * from ...
Can you give me an exampl, I cant get it :(
$query = "select news.User_ID as userid,* from news,users where
news.UserID=users.UserID order by news.News_ID desc";
When you fetch the results the value of news.UserID will be in the result
array as index ['userid'] (or [0])
--
Tom Thackrey www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Tom Thackrey wrote: On 19-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote:
Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of these?
select news.User_ID as userid, * from ...
Since the WHERE clause is making them equal it does not matter which
variable ends up in the Select list; both is ok too. In order to better
abbreviate the WHERE predicates you could correlate the tables to an
alias.
$query = "select * from news a, users b where a.User_ID = b.User_ID
order by a.News_ID DESC"
What particular problem were you having?
Not absolutely sure of the syntax....you MAY need the AS keyword for the
correlation variable: ... news AS a, users AS b ....
Disclaimer: Not tested
Chris
Always remember, you are unique...just like everyone else.
Thanks both, been a great help.
The problem I was having is what if I wanted to get both User_ID's from both
tables... the array is only going to hold one of them.
So I was wondering If I could use an alias, but everything I tried I got
errors. So far this is what I have:
select * from users, news where users.User_ID = news.User_ID order by
news.News_ID DESC;
But there will only be one User_ID in my array... how would I change this to
make an alias? So like News.User_ID, User.User_ID?
Maybe I should have a seperate table to take this out of the news table as
it shouldn't really be there, compound enitity :S
"pomasl<nospam> @starband.net>" <"pomasl<nospam> wrote in message
news:GU****************@fe25.usenetserver.com... Tom Thackrey wrote: On 19-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote:
Currently im using this
$query = "select * from news, users where news.User_ID = users.User_ID order by news.News_ID DESC"
only problem is both tables have User_ID, how can I make aliases of
these?
select news.User_ID as userid, * from ... Since the WHERE clause is making them equal it does not matter which variable ends up in the Select list; both is ok too. In order to better abbreviate the WHERE predicates you could correlate the tables to an alias.
$query = "select * from news a, users b where a.User_ID = b.User_ID order by a.News_ID DESC"
What particular problem were you having? Not absolutely sure of the syntax....you MAY need the AS keyword for the correlation variable: ... news AS a, users AS b ....
Disclaimer: Not tested
Chris Always remember, you are unique...just like everyone else.
On 21-Mar-2004, "Hayden Kirk" <sp**@spam.com> wrote: The problem I was having is what if I wanted to get both User_ID's from both tables... the array is only going to hold one of them.
So I was wondering If I could use an alias, but everything I tried I got errors. So far this is what I have:
select * from users, news where users.User_ID = news.User_ID order by news.News_ID DESC;
But there will only be one User_ID in my array... how would I change this to make an alias? So like News.User_ID, User.User_ID?
I think I answered your question before, but here it is again
select users.User_ID as userid, * from ...
This will create an extra column called userid which will contain
users.User_ID.
You say you want both users.User_ID and news.User_ID but your select will
ensure they have the same value, so why do you need both??
If you really want both you would code something like
select users.User_ID as usersuserid, news.User_ID as newsuserid, * from...
This will create two extra columns, usersuserid and newsuserid.
--
Tom Thackrey www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bert Sierra |
last post by:
Hello --
I have what appears to be a simple PHP+MySQL query, but Dreamweaver
consistently generates PHP code which won't parse. I've stared at the
PHP code for several hours now, and I can't...
|
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary...
|
by: red85 |
last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an
alpha and i don't know if someone else has already posted this
problem:
when i execute this sql
UPDATE tableX SET...
|
by: Fatt Shin |
last post by:
Hi,
I'm running MySQL 4.0.13, connecting from PowerBuilder 9 using ODCB
Connector 3.51.
I'm facing a problem where whenever I issue a SELECT COUNT(*) statement
from PowerBuilder, I always get SQL...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
| |
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer...
|
by: Fred |
last post by:
Hello,
Our website is currently developed in ASP/Mysql 4.
The dedicated servers on which it is currently hosted arrive at saturation.
Here is their configuration:
- 1 server PIV 2,8Ghz 1GB...
|
by: IamtheEvster |
last post by:
Hi All,
I am currently using PHP 5 and MySQL 5, both on Fedora Core 5. I am
unable to call a MySQL stored procedure that returns output parameters
using mysql, mysqli, or PDO. I'm having a...
|
by: jrs_14618 |
last post by:
Hello All,
This post is essentially a reply a previous post/thread
here on this mailing.database.myodbc group titled:
MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode
I was...
|
by: ojorus |
last post by:
Hi!
My company make several flash-based games, and I use php to communicate with
mysql to provide highscore-lists.
My problem is this:
When I save a player's score in the mysql-table, I want to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |