mysql模糊列标题

Okay so i have a search code that looks into two tables. I know that the ambiguity comes from the fact that there is a column "title" in both tables (tables named disc track).

now my fix was this.

$query="SELECT * FROM  disc, track WHERE Artist LIKE '%$trimmed%' OR disc.Title LIKE 

'%$trimmed%' OR Year LIKE '%$trimmed%' OR Genre LIKE '%$trimmed%' LIMIT 0, 30";

.

 Notice: Undefined index: disc.Title in C:\xampp\htdocs\search.php on line 61

I have been searching everywhere, and anywhere I go it says that that code is correct. but whenever I run through a search it says disc.Title doesn't exist (when i only search one of the tables it can find Title)

any ideas?

SELECT d.*, t.* FROM  disc d, track t WHERE t.Artist LIKE '%$trimmed%' OR d.Title LIKE '%$trimmed%' OR Year LIKE '%$trimmed%' OR t.Genre LIKE '%$trimmed%' LIMIT 0, 30

You should use the table information / prefix for all join and select items.

run $query="SELECT * FROM disc, track WHERE Artist LIKE '%$trimmed%'" does it work?

it is the OR disc.Title in that is throwing you off.

you need to complete the disk.Title expression. OR disc.Title LIKE '%$trimmed%'

also as far as running SQL goes, you should explicitly write your joins.

SELECT * 
FROM disc
INNER JOIN track
    ON disk.id = track.disk_id
WHERE (
    [disk or track?].Artist LIKE '%$trimmed%' 
    OR disc.Title LIKE '%$trimmed%'
)