+ Post New Thread
Results 1 to 2 of 2
Coding Thread, Simple MySql Query in Coding and Web Development; I have a DB with two tables in it, one called Subjects and there called Subject Descriptions: Subjects: Column 1 ...
  1. #1

    Join Date
    Apr 2006
    Location
    UK
    Posts
    939
    Thank Post
    39
    Thanked 70 Times in 54 Posts
    Rep Power
    29

    Simple MySql Query

    I have a DB with two tables in it, one called Subjects and there called Subject Descriptions:

    Subjects:

    Column 1 = SubjectID
    Column 2 = Subject

    SubjectDescriptions:

    Column 1 = SubjectID
    Column 2 = Year (This just details which year the description relates to)
    Column 3 = SubjectDescription

    I want to 'Select * SubjectDescription from SubjectDescriptions'

    E.g. 1,Y7,Maths is about Numbers and stuff

    But I then want to change the SubjectID to the name of the subject, and icant for the life of me remember how?

    can anyone help?

  2. #2

    Join Date
    Feb 2006
    Location
    Isle of Wight, UK
    Posts
    149
    Thank Post
    28
    Thanked 28 Times in 25 Posts
    Rep Power
    21
    Something along the lines of:

    Code:
    Select Subject,Year,SubjectDescription from Subjects,SubjectDescriptions where Subjects.SubjectID=SubjectDescriptions.SubjectID
    That should give you a result with the relevant fields. If you want the SubjectID as well, just include that in the list of fields to return. It's usually good practice not to use the 'select *' approach, as it can result in excessive memory usage if you don't intend to use all the fields.

    Stephen

  3. Thanks to SteveMC from:

    danIT (24th September 2008)

SHARE:
+ Post New Thread

Similar Threads

  1. Simple 1.5 doesn't look right
    By SimpleSi in forum EduGeek Joomla 1.5 Package
    Replies: 7
    Last Post: 25th May 2008, 11:21 AM
  2. Simple Gallery
    By Scotmk in forum Web Development
    Replies: 2
    Last Post: 5th March 2008, 12:14 PM
  3. Query of existing query data in PHP
    By markwilliamson2001 in forum Web Development
    Replies: 5
    Last Post: 5th October 2007, 08:43 AM
  4. Simple iPhoto query
    By dagza in forum Mac
    Replies: 4
    Last Post: 15th June 2006, 09:11 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •