Re: How to make so I only need to specify the id once..

2005-02-22 Thread SGreen
"Martijn Tonies" <[EMAIL PROTECTED]> wrote on 02/21/2005 10:20:28 AM:

> 
> 
> > Hi,
> > why not try:
> > SELECT COUNT(s.Id)+COUNT(se.Id)
> > FROM subs s
> > INNER JOIN subs_erased se ON s.Id=se.Id
> > WHERE s.Id=1;
> >
> > /Johan
> 
> This won't return the same result if there's no entries
> in "subs_erased" for the ID = 1.
> 
> With regards,
> 
> Martijn Tonies
> Database Workbench - developer tool for InterBase, Firebird, MySQL & MS 
SQL
> Server
> Upscene Productions
> http://www.upscene.com
> 
> > Joppe A wrote:
> > > Hello,
> > >
> > > I have a small problem that is probably easy to fix but it is to
> advanced for me as a "newbe". In my sql-query (below) have I the ID
> specified twice, I wonder if there is a easy way to solve it so I only 
need
> to write my ID once in the query?
> > >
> > > SELECT (SELECT COUNT(*) FROM subs WHERE id=1) + (SELECT COUNT(*) 
FROM
> subs_erased WHERE id=1);
> > >
> > > Thanks in advance!
> >
> >
> 

It should if he changed the INNER JOIN to a LEFT JOIN.

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine


Re: How to make so I only need to specify the id once..

2005-02-21 Thread Johan Höök
Hi Martijn,
yes of course you're right but
SELECT COUNT(s.Id)+
  (SELECT COUNT(se.Id) FROM subs_erased se WHERE s.Id=se.Id)
FROM subs s
WHERE s.Id=1
might work, at least in 4.1.x. I did test it with 4.1.9.
/Johan
Martijn Tonies wrote:

Hi,
why not try:
SELECT COUNT(s.Id)+COUNT(se.Id)
FROM subs s
INNER JOIN subs_erased se ON s.Id=se.Id
WHERE s.Id=1;
/Johan

This won't return the same result if there's no entries
in "subs_erased" for the ID = 1.
With regards,
Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com

Joppe A wrote:
Hello,
I have a small problem that is probably easy to fix but it is to
advanced for me as a "newbe". In my sql-query (below) have I the ID
specified twice, I wonder if there is a easy way to solve it so I only need
to write my ID once in the query?
SELECT (SELECT COUNT(*) FROM subs WHERE id=1) + (SELECT COUNT(*) FROM
subs_erased WHERE id=1);
Thanks in advance!





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

Re: How to make so I only need to specify the id once..

2005-02-21 Thread Martijn Tonies


> Hi,
> why not try:
> SELECT COUNT(s.Id)+COUNT(se.Id)
> FROM subs s
> INNER JOIN subs_erased se ON s.Id=se.Id
> WHERE s.Id=1;
>
> /Johan

This won't return the same result if there's no entries
in "subs_erased" for the ID = 1.

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server
Upscene Productions
http://www.upscene.com

> Joppe A wrote:
> > Hello,
> >
> > I have a small problem that is probably easy to fix but it is to
advanced for me as a "newbe". In my sql-query (below) have I the ID
specified twice, I wonder if there is a easy way to solve it so I only need
to write my ID once in the query?
> >
> > SELECT (SELECT COUNT(*) FROM subs WHERE id=1) + (SELECT COUNT(*) FROM
subs_erased WHERE id=1);
> >
> > Thanks in advance!
>
>






> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Re: How to make so I only need to specify the id once..

2005-02-21 Thread Johan Höök
Hi,
why not try:
SELECT COUNT(s.Id)+COUNT(se.Id)
FROM subs s
INNER JOIN subs_erased se ON s.Id=se.Id
WHERE s.Id=1;
/Johan
Joppe A wrote:
Hello,
I have a small problem that is probably easy to fix but it is to advanced for me as a 
"newbe". In my sql-query (below) have I the ID specified twice, I wonder if 
there is a easy way to solve it so I only need to write my ID once in the query?
SELECT (SELECT COUNT(*) FROM subs WHERE id=1) + (SELECT COUNT(*) FROM 
subs_erased WHERE id=1);
Thanks in advance!

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]

How to make so I only need to specify the id once..

2005-02-21 Thread Joppe A
Hello,

I have a small problem that is probably easy to fix but it is to advanced for 
me as a "newbe". In my sql-query (below) have I the ID specified twice, I 
wonder if there is a easy way to solve it so I only need to write my ID once in 
the query?

SELECT (SELECT COUNT(*) FROM subs WHERE id=1) + (SELECT COUNT(*) FROM 
subs_erased WHERE id=1);

Thanks in advance!
-- 
___
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]