Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old April 15th, 2003, 04:52 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
mySQL problem

Hi,

I have some mysql problems

here is an example table

Postings
pid mid comments
1 1 hi
2 1 bye
3 2 " "

pid is a primary key

here is the othe table:

Timslot
id pid comment
1 1 hi
2 1 hi
3 3 " "

pid here is a reference to pid in Postings

Here is the functions I use:
php Code:
Original - php Code
  1.  
  2.  
  3. $mid = 1;
  4. $get_pid = mysql_query(stripslashes("SELECT pid FROM ta_posting WHERE mid = '$mid'"));
  5.  


What this does is gets pid 1, when I really want is pid 2. How can I do this so table Timeslot would look like this:

Timslot
id pid comment
1 1 hi
2 2 bye
3 3 " "

Thanks.

Reply With Quote
  #2  
Old April 16th, 2003, 06:11 PM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: mySQL problem

It's really unclear what you want to do. Can you please explain what is it the tables contain, what is mid, etc.

Reply With Quote
  #3  
Old April 17th, 2003, 09:04 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: mySQL problem

mid is short for member id.
pid is short for posting id.

It's just that when I query the Posting table for pid's under a certian mid, (ie. mid 1) I'll will get pid 1, when I really want pid 2.


Reply With Quote
  #4  
Old April 18th, 2003, 06:05 AM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: mySQL problem

So you want the latest posting from a member or what? "I want 2 but not 1" isn't telling us much

Reply With Quote
  #5  
Old April 19th, 2003, 04:41 PM
ricesteam ricesteam is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 25 ricesteam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: mySQL problem

Yes, the lastest polling is correct.

Reply With Quote
  #6  
Old April 19th, 2003, 06:57 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: mySQL problem

use the following query:

SELECT Max(pid) FROM ta_posting WHERE mid = '$mid'"

this will always return the largest value of PID for a given MID

Reply With Quote
  #7  
Old April 19th, 2003, 08:35 PM
xs0 xs0 is offline
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: Ljubljana, Slovenia
Posts: 760 xs0 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: mySQL problem

select * from posting where mid=1 order by pid desc

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > mySQL problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT