I don’t know what its called so I’ll just try to explain.
Lets say there are two tables, tableA and tableB.
- In
tableAthere is a column that has a number (eg. 105) - In
tableBthere is a column that has a text (eg. ‘This’)
105 means ‘This’.
So a number is stored in the A table w/c has a meaning in the B table.
I want to get the tableA number, but when its displayed it will display ‘This’.
Logic: If result from A is 105, then display equivalent text from B where id is 105.
Displays: THIS
SELECT TOP 1
CHAR_KEY AS charid,
USER_KEY AS userid,
CONVERT(VARCHAR,substring(char_data, 9, 16)) AS name,
CONVERT(INT,cast(reverse(substring(char_data, 7, 2)) as BINARY(2))) AS level,
CONVERT(INT,substring(char_data, 25, 1)) AS type,
CONVERT(INT,cast(reverse(substring(char_data, 263, 2)) as BINARY(2))) AS strength,
CONVERT(INT,cast(reverse(substring(char_data, 265, 2)) as BINARY(2))) AS wisdom,
CONVERT(INT,cast(reverse(substring(char_data, 267, 2)) as BINARY(2))) AS dexterity,
CONVERT(INT,cast(reverse(substring(char_data, 269, 2)) as BINARY(2))) AS charisma,
CONVERT(INT,cast(reverse(substring(char_data, 271, 2)) as BINARY(2))) AS intelligence,
CONVERT(INT,cast(reverse(substring(char_data, 273, 2)) as BINARY(2))) AS constitution,
CONVERT(INT,cast(reverse(substring(char_data, 309, 4)) as BINARY(4))) AS fame,
CONVERT(INT,cast(reverse(substring(char_data, 33, 4)) as BINARY(4))) AS guild,
CONVERT(INT, substring(char_data, 261, 1)) AS permission
FROM CHAR_DATA0 WHERE CONVERT(INT, substring(char_data, 261, 1))=0x00 ORDER BY level DESC
The query to get the name of the guild.
SELECT
guild_name
FROM guild_data WHERE guild_key=guild
What I’m trying to get is the guild.
Example from the first SELECT query the guild results: 518
on the table guild_data, a column guild_name contains the name of the guild 518.
518 is the guild_key.
Please help, Thank you.
1 Answer