User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 374,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,542 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 356 | Replies: 2 | Solved
Reply
Join Date: Mar 2008
Posts: 68
Reputation: queenc is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
queenc queenc is offline Offline
Junior Poster in Training

query

  #1  
Apr 21st, 2008
hi
i have two tables,i want to display the details in startpost and based on the userid i want to display the username
ie i want to print
posttitle,date,name
using single query please help
CREATE TABLE `creuser` (
  `uid` int(11) NOT NULL auto_increment,
  `username` varchar(100) NOT NULL,
    UNIQUE KEY `uid` (`uid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;

CREATE TABLE `startpost` (
    `posttitle` varchar(300) NOT NULL,
  `userid` int(50) NOT NULL,
  `dat` datetime NOT NULL,
  PRIMARY KEY  (`postid`),
  UNIQUE KEY `postid` (`postid`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2007
Location: Birmingham
Posts: 368
Reputation: Fungus1487 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 35
Fungus1487's Avatar
Fungus1487 Fungus1487 is offline Offline
Posting Whiz

Re: query

  #2  
Apr 21st, 2008
SELECT startpost.posttitle, startpost.dat, creuser.username FROM startpost INNER JOIN creuser ON startpost.userid = creuser.uid
That will display all the startpost data with the username for the startposts. Specifying a Where clause like below will let you show one startpost record based on its id.
SELECT startpost.posttitle, startpost.dat, creuser.username FROM startpost INNER JOIN creuser ON startpost.userid = creuser.uid WHERE startpost.postid = 1

This is really quite basic and i suggest you read some articles explaining "JOINS" a good one is here w3schools
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Reply With Quote  
Join Date: Mar 2008
Posts: 68
Reputation: queenc is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 2
queenc queenc is offline Offline
Junior Poster in Training

Re: query

  #3  
Apr 21st, 2008
thanks a lot
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 5:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC