|
ennye Novice
Joined: 17 Dec 2007 Posts: 49
|
Posted: 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) |
|
|
|
ennye Novice
Joined: 17 Dec 2007 Posts: 49
|
Posted: Mon May 28, 2012 8:18 pm |
No clues?
Please give any examples how to query database fields. |
|
|
|
Progonoi Magician
Joined: 28 Jan 2007 Posts: 430
|
Posted: 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
-------------------------------- |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: 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 |
|
|
|
ennye Novice
Joined: 17 Dec 2007 Posts: 49
|
Posted: 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.
|
|
|
|
Daern Sorcerer
Joined: 15 Apr 2011 Posts: 809
|
Posted: 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}} |
|
|
|
|
|
|