[Scottish] sql

scottish@mailman.lug.org.uk scottish at mailman.lug.org.uk
Tue Jan 28 17:35:01 2003


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C2C6E2.97172460
Content-Type: text/plain; charset="iso-8859-1"

*****************************************************************************
This email and any files transmitted with it are intended solely
 for the use of the individual or entity to whom they are addressed.
*****************************************************************************

 
> appologies (and feeling really silly right now)
> this trivial question was not meant for this group. 
> I was just looking for a quick and lazy answer from a work 
> mate whos an informix 4gl answer so I could quickly test something.
> 
> On Tuesday 28 January 2003 3:16 pm, Tam McLaughlin wrote:
> > i am trying something in mysql but can't remember any sql.
> > Say i have a field called name in table 1 and i want to select the
> > name and the number of times that name appears in the table,
> > how would i do it?
> > If u can tell me, i can find the equiv syntax in mysql
> > thanks.

No exactly sure if you;re after the number of times the value "name" appears
in the name of a field or whether a field name has a value "whatever" x
number of times

Assuming the latter

select count(*) as 'no_of_times'
from table1
where name = 'whatever'

last one can be 
   where name like '%whatever%' if you want to find the value anywhere in
the string

cds

------_=_NextPart_001_01C2C6E2.97172460
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [Scottish] sql</TITLE>
</HEAD>
<BODY><CODE><FONT SIZE=3D3>************************************************=
*****************************<BR>
This email and any files transmitted with it are intended solely<BR>
 for the use of the individual or entity to whom they are addressed.<BR>
***************************************************************************=
**<BR>
<BR>
</FONT></CODE>

<P><FONT SIZE=3D2>&nbsp;</FONT>
<BR><FONT SIZE=3D2>&gt; appologies (and feeling really silly right now)</FO=
NT>
<BR><FONT SIZE=3D2>&gt; this trivial question was not meant for this group.=
 </FONT>
<BR><FONT SIZE=3D2>&gt; I was just looking for a quick and lazy answer from=
 a work </FONT>
<BR><FONT SIZE=3D2>&gt; mate whos an informix 4gl answer so I could quickly=
 test something.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; On Tuesday 28 January 2003 3:16 pm, Tam McLaughlin =
wrote:</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; i am trying something in mysql but can't remem=
ber any sql.</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; Say i have a field called name in table 1 and =
i want to select the</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; name and the number of times that name appears=
 in the table,</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; how would i do it?</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; If u can tell me, i can find the equiv syntax =
in mysql</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; thanks.</FONT>
</P>

<P><FONT SIZE=3D2>No exactly sure if you;re after the number of times the v=
alue &quot;name&quot; appears in the name of a field or whether a field nam=
e has a value &quot;whatever&quot; x number of times</FONT></P>

<P><FONT SIZE=3D2>Assuming the latter</FONT>
</P>

<P><FONT SIZE=3D2>select count(*) as 'no_of_times'</FONT>
<BR><FONT SIZE=3D2>from table1</FONT>
<BR><FONT SIZE=3D2>where name =3D 'whatever'</FONT>
</P>

<P><FONT SIZE=3D2>last one can be </FONT>
<BR><FONT SIZE=3D2>&nbsp;&nbsp; where name like '%whatever%' if you want to=
 find the value anywhere in the string</FONT>
</P>

<P><FONT SIZE=3D2>cds</FONT>
</P>

</BODY>
</HTML>
------_=_NextPart_001_01C2C6E2.97172460--