SQL Tables

This forum is now closed as part of retiring phpBB2.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

This forum is now closed due to phpBB2.0 being retired.
Post Reply
cacs
Registered User
Posts: 41
Joined: Thu Feb 06, 2003 10:36 pm

SQL Tables

Post by cacs »

hey any help with a query would be appreciated... here is the table schema

Schema:
CD: (cd_id, cd_name, year_of_release, label)
TRACK: (track_id, track_name, duration, cd_id)
ARTIST: (artist_id, artist_name)
GRP: (grp_id, grp_name)
PERFORMS: (artist_id, track_id, instrument)
ARTIST_RELEASE: (artist_id, cd_id)
GROUP_RELEASE: (group_id, cd_id)
FORMED: (artist_id, group_id, date_joined)


Query =

How many CD's are released by each label?

I think its to use a GROUP BY and COUNT sql statment
User avatar
Jim_UK
Former Team Member
Posts: 18478
Joined: Tue Oct 12, 2004 5:36 pm
Location: Darwen N.West UK

Post by Jim_UK »

I have moved this to Mod Writers discussion for you.

For future reference we have quite strict rules about what can be posted in General discussion.

Jim
The truth is out there.
Unfortunately they will not let you anywhere near it!
cacs
Registered User
Posts: 41
Joined: Thu Feb 06, 2003 10:36 pm

Post by cacs »

thanks jim!
User avatar
drathbun
Former Team Member
Posts: 12204
Joined: Thu Jun 06, 2002 3:51 pm
Location: TOPICS_TABLE
Contact:

Re: SQL Tables

Post by drathbun »

cacs wrote: Schema:
CD: (cd_id, cd_name, year_of_release, label)

How many CD's are released by each label?

Is "CD" a table? If so...

Code: Select all

select label, count(cd_id) as label_count
from CD
group by label
I blog about phpBB: phpBBDoctor blog
Still using phpbb2? So am I! Click below for details
Image
User avatar
Marnboorapa
Registered User
Posts: 84
Joined: Sat Jan 08, 2005 3:19 pm
Location: Thailand
Contact:

Post by Marnboorapa »

It's very easy

1. tell phpbb to know you new table

Code: Select all

//
// OPEN FILE
//

includes/constants.php

//
// FIND THIS CODE
//

?>

//
// BEFORE ADD
//

define('CD_TABLE', $table_prefix.'your table name');
define('TRACK_TABLE', $table_prefix.'your table name');
define('ARTIST_TABLE', $table_prefix.'your table name');
define('GRP_TABLE', $table_prefix.'your table name');
define('PERFORMS_TABLE', $table_prefix.'your table name');
define('ARTIST__RELEASE_TABLE', $table_prefix.'your table name');
define('GROUP_RELEASE_TABLE', $table_prefix.'your table name');
define('FORMEC_TABLE', $table_prefix.'your table name');
2. place SQL tag to your phpbb file.

Code: Select all

//
// OPEN YOUR FILE.PHP (which you want to query SQL )
//

$sql = "SELECT *
FROM " . CD_TABLE . " , " . TRACK_TABLE . ", " . ARTIST_TABLE . ", " . GRP_TABLE . ", " . PERFORMS_TABLE . ", " . ARTIST_RELEASE_TABLE . ", " . GROUP_RELEASE_TABLE . ", " . FORMED_TABLE . "; 
I'm sure that any more you can do it yourself. 8)
Post Reply

Return to “[2.0.x] MOD Writers Discussion”