Sql Selection Issues

free web hosting
Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Sql Selection Issues

magiccode9
CODE
CREATE TABLE pbm_album (
    id TINYINT(8) AUTO_INCREMENT,
    parent_id TINYINT(8)
    pbm_name VARCHAR(100),
    pbm_desc VARCHAR(150),
    pbm_order TINYINT(8),
    pbm_image varchar(100),
    pbm_cat_id TINYINT(8),
    pbm_create_date int NOT NULL,
    FOREIGN KEY pbm_cat_id REFERENCES pbm_catalog(id),
    PRIMARY KEY(id)
)

CREATE TABLE pbm_photo (
    id TINYINT(8) AUTO_INCREMENT,
    pbm_name varchar(20) NOT NULL,
    pbm_title varchar(60) NULL,
    pbm_album_id TINYINT(8) NOT NULL,
    pbm_create_date int NOT NULL,
    FOREIGN KEY pbm_album_id REFERENCES pbm_album(id),
    PRIMARY KEY(id)
)


hi I got a issue when selecting some data.
What I'am doing is to select all albums and photos that presents in the current album. However, for now I just can select all albums under the current album.

This is the statement I do obtain albums
CODE
SELECT a.id, a.pbm_name, a.pbm_desc, a.create_date, count(p.pbm_album_id)
   FROM pbm_album a
     LEFT JOIN pbm_photo p ON
        a.pbm_parent_id = p.pbm_album_id AND p.pbm_album=[album_id]
           GROUP BY a.pbm_name
                ORDER BY a.create_date


It provides me all info about album, but when a album that both hold albums and photos.
How do I select both of it as the tables structure are different between the two.


[ref]
[ Album Name ] - [ Some Photos ] [ Album Name ] - [ Album Name ]

Thanks
Eric,

 

 

 


Reply

derickkoo
QUOTE(magiccode9 @ Nov 2 2006, 01:05 PM) *

CODE
CREATE TABLE pbm_album (
    id TINYINT(8) AUTO_INCREMENT,
    parent_id TINYINT(8)
    pbm_name VARCHAR(100),
    pbm_desc VARCHAR(150),
    pbm_order TINYINT(8),
    pbm_image varchar(100),
    pbm_cat_id TINYINT(8),
    pbm_create_date int NOT NULL,
    FOREIGN KEY pbm_cat_id REFERENCES pbm_catalog(id),
    PRIMARY KEY(id)
)

CREATE TABLE pbm_photo (
    id TINYINT(8) AUTO_INCREMENT,
    pbm_name varchar(20) NOT NULL,
    pbm_title varchar(60) NULL,
    pbm_album_id TINYINT(8) NOT NULL,
    pbm_create_date int NOT NULL,
    FOREIGN KEY pbm_album_id REFERENCES pbm_album(id),
    PRIMARY KEY(id)
)


hi I got a issue when selecting some data.
What I'am doing is to select all albums and photos that presents in the current album. However, for now I just can select all albums under the current album.

This is the statement I do obtain albums
CODE
SELECT a.id, a.pbm_name, a.pbm_desc, a.create_date, count(p.pbm_album_id)
   FROM pbm_album a
     LEFT JOIN pbm_photo p ON
        a.pbm_parent_id = p.pbm_album_id AND p.pbm_album=[album_id]
           GROUP BY a.pbm_name
                ORDER BY a.create_date


It provides me all info about album, but when a album that both hold albums and photos.
How do I select both of it as the tables structure are different between the two.
[ref]
[ Album Name ] - [ Some Photos ] [ Album Name ] - [ Album Name ]

Thanks
Eric,



Hey, does a column "pbm_album" in the table "pbm_photo" ???

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Similar Topics

Keywords : sql selection issues

  1. Php Sessions And Post Variables Issues - My script dosent seem to work as intended (1)
  2. Using Multiple Selection Array In Table To Order Data - Using multiple selection array in table to order data (1)
    have a form that has a multiple select choice, like this: CODE <form method="post"
    action="display.php" <select multiple name="selectsort[]">
    <option value="code">Code</option> <option
    value="amount">Amount</option> <option value="dateammended">Date
    Ammended</option> <option value="expreviewdate">Expiration/Review
    Date</option> <option value="effectivedate">Effective Date</option>
    <option value="e...
  3. Selection Problem - (4)
    I need help on a join, I think I have it mostly done, but I know my syntax isn't right. First
    off, to give you an idea, I have two tables, plus my session variables. I'm first selecting from
    the table: user_resources where the user_id = that of the $_SESSION's, and in
    user_resources, there are three fields, user_id, resource_id, and amount, and I wish to print all of
    this. But the hitch to it is, resource_id is an integer. In another table called resources, are the
    fields id and name. The resource_id = resources.id, and I want to print the name associat...
  4. File Uploading Issues - (2)
    i have never tried to have files uploaded and i am still not able to do so. here is the codes that i
    am using right out of the php manual and it still isnt working. i have also listed the
    warnings/errors listed on the resulting page. my permissions are set to 777 also. i have a folder
    set up on my server as "uploads". i am however not sure if i have a default temp folder on my
    server. can anyone help me figure out what i am not doing correctly or what my next step is? this
    is the form that i am using: html Code: CODE <form enctype="multipart/form-data" ...
  5. Php/mysql Search Engine Help - Having issues displaying results (1)
    I've been using a tutorial
    (http://www.devarticles.com/c/a/MySQL/Developing-A-Site-Search-Engine-With-PHP-And-MySQL/) at this
    address to help me get started on building my own search engine. I've completed the tutorial but
    when I run the search, I get no results on the results page. I'm wondering if anyone will take a
    look at this script and see if they can figure out why my I'm not getting any results displayed.
    I'm using phpMyAdmin to build the database and simple notepad to build the PHP script. CODE
    <?php $submit = $_POST[&...



Looking for sql, selection, issues

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for sql, selection, issues

*MORE FROM TRAP17.COM*
advertisement



Sql Selection Issues



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE