Reputation: 21
I have a question for my search bar: In Account Management, I have list of accounts And this is the Account table:
*AccountID (Example: 1) *AccountName (Example: Test) (...)
Now, When I type Test, or 1, I find my result.
My problem is how to search by typing one of character name, this is the characters table:
*CharacterName (Example: Charac) *AccountID (1 [the same accountID])
I've tried INNER JOIN but it's not working, and i think it isn't the correct method, this is my SQL code
$sql = "SELECT * FROM account INNER JOIN characterrecord ON characterrecord.AccountId = account.AccountId WHERE account.AccountId LIKE '%" . $name . "%' OR account.Name LIKE '%" . $name ."%' OR characterrecord.Name LIKE '%" . $name ."%' GROUP BY account.accountid LIMIT ".$_GET['page'].",".$page_accountnumber;
$req = mysql_query($sql) or die('Erreur SQL !<br />'.$sql.'<br />'.mysql_error());
while ($acc = mysql_fetch_array($req)) {
....
What I want: If I type Charac or char ... I must see 1/Test (Character account infos).
Sorry for my bad english, I'm french, and thank you so much!
Upvotes: 0
Views: 35
Reputation: 15971
Since the tables share certain field names, it may be necessary to specify or alias the fields in the SELECT
clause to ensure whatever framework you are handling them with is capable of distinguishing them.
Upvotes: 1