Just to give you another convention, I do:
1) tbl for tables, with the singular, like tblEmployee -- not really
necessary in SQL statements directly, but I use a class to generate SQL
statements, so in PHP function calls I can tell what's a table more easily
2) I capitalize field names with n
> I used to be in the plural camp. But I've become fond of the singular
> camp. That way the table can more easily match the names of the columns.
> This makes things easier when it comes to making automatic tools for
> sanitizing input and reverse engineering databases.
Makes sense. I will
Hi John:
> I am a bit stuck with legacy naming that is all over the place.
Fun fun fun!
> Is there a defacto standard for schema naming?
There are loads of naming standards. I think very highly of Peter
Gulutzan. The live version of the web page has been yanked, but
Archive.org to the resc
AIL PROTECTED]>
To: "NYPHP Talk"
Sent: Wednesday, April 23, 2008 3:41 PM
Subject: Re: [nyphp-talk] MySQL - SQL Question
On Tue, Apr 22, 2008 at 6:09 PM, Daniel Convissor
<[EMAIL PROTECTED]> wrote:
Hi John:
[snip]
Don't use sub selects unless really necessary. They k
On Tue, Apr 22, 2008 at 6:09 PM, Daniel Convissor
<[EMAIL PROTECTED]> wrote:
> Hi John:
> [snip]
> Don't use sub selects unless really necessary. They kill performance.
Yeah, that's why I knew what I was doing was wrong.
> Also also, use a consistent naming convention. You've got plural
> d
Hi Kristina,
> //==
> SELECT i.id, i.name, i.whatever,
> COALESCE(i.specific1, d.default1) as val1,
> COALESCE(i.specific2, d.default2) as val2
> FROM tblInstance i
> LEFT OUTER JOIN tblDefault d
> ON i.foreignKey = d.primaryKey;
>
> COALESCE selects the first non-null value of its arguments,
//==
SELECT i.id, i.name, i.whatever,
COALESCE(i.specific1, d.default1) as val1,
COALESCE(i.specific2, d.default2) as val2
FROM tblInstance i
LEFT OUTER JOIN tblDefault d
ON i.foreignKey = d.primaryKey;
COALESCE selects the first non-null value of its arguments, and the
left outer join makes
Hi John:
On Tue, Apr 22, 2008 at 01:31:52PM -0400, John Campbell wrote:
>
> I have a products table with a standard auto number primary key, and a
> descriptions table that is keyed off the product id and a language id
> ('en','es','zh_cn', etc)
...
> SELECT product.id, product.price, (SELECT d.d
On Tue, Apr 22, 2008 at 2:10 PM, Kenneth Dombrowski <[EMAIL PROTECTED]> wrote:
> SELECT
> p.id ,
> p.price ,
> IF(d.description, d.description, en.description) AS description ,
> IF(d.lang_id, d.lang_id, en.lang_id) AS lang_id
> FROM product AS p
> INNER JOIN user
Hi John,
On 08-04-22 13:31 -0400, John Campbell wrote:
>
> I have a products table with a standard auto number primary key, and a
> descriptions table that is keyed off the product id and a language id
> ('en','es','zh_cn', etc)
>
> I want to join the description table to the product table on
Ah, assuming you don't know the language prior to creating the query,
I think you'd use something like:
SELECT
product.id
, product.price
, IF (lang_id IS NULL, 'en', lang_id) AS lang_id
FROM
product
LEFT JOIN
descriptions ON product.id = descriptions.produc
11 matches
Mail list logo