Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
ennye
Novice


Joined: 17 Dec 2007
Posts: 49

PostPosted: Thu Apr 12, 2012 11:12 pm   

Database query.
 
Short example:
Database players.

Code:
Row Rec  Name   Wep Spec
1   1pl  Hungry Kn  KS
2   2pl  Ungry  Sw  BS


How to query database?
I need Spec for player Name Ungry.

I tried:
#say %db(%find(Ungry,,Name),Spec)

Returns:
KS (%find gives both records, as "ungry" matches both names) as first appearance. This is wrong.

Questions:
How to match -exactly- the name?
How to read exact database field ? (Read Spec or Wep field of a record from the name i gave)
Reply with quote
ennye
Novice


Joined: 17 Dec 2007
Posts: 49

PostPosted: Mon May 28, 2012 8:18 pm   
 
No clues?
Please give any examples how to query database fields.
Reply with quote
Progonoi
Magician


Joined: 28 Jan 2007
Posts: 430

PostPosted: Mon May 28, 2012 10:18 pm   
 
Database sux, database variable rox!

'Nuff said.
_________________
The Proud new owner of CMud.

--------------------------------
Intel Core i5-650 3,2GHz
4 DD3 RAM
GTX 460 768MB
Win 7 Home Premium 64x
--------------------------------
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Tue May 29, 2012 4:24 am   
 
database = database variable. Everything that works on one will work on the other (sort of).

That said, the database is not a real database and so doesn't have many of the features a real database would have. Since you are using CMud, you might want to port over to an SQLite database and use the %sqldb() and %sql() functions.
_________________
EDIT: I didn't like my old signature
Reply with quote
ennye
Novice


Joined: 17 Dec 2007
Posts: 49

PostPosted: Thu Jan 16, 2014 11:14 am   
 
Database variable is ok with 2 fields. When you got many fields database is the only clear solution , multiple database variables make lot of mess. (f.e. you cant easy delete one row when you got 5 database variables connected with row numbers.
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Thu Jan 16, 2014 5:46 pm   
 
This is a two year old topic, but that's not entirely true since you can nest them. For that data, I would use something like this:
Code:
{{rec=1pl|name=Hungry|wep=Kn|Spec=KS} | {rec=2pl|name=Ungry|wep=Sw|Spec=BS}}
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net