Good day, i have been trying to do a simple search from three tables, how posdible is that. I have tables like
- Songs
- Videos
- Posts
The songs table has columns like song_title,song_author. The videos table has columns like videos_title,videos_author. While the posts table also have post_title, post_author.
But i want to search a keyword from a search input box in these columns "Song_title,song_author,video_title,video_,author,post_title"
What i tried so far seems to be completely useless which is:
$query = "(SELECT song_title, song_author, 'song' as type FROM songs WHERE song_title LIKE '%" . $keyword . "%' OR song_author LIKE '%" . $keyword ."%')
UNION
(SELECT video_title, video_author, 'video' as type FROM videos WHERE video_title LIKE '%" . $keyword . "%' OR video_author LIKE '%" . $keyword ."%')
UNION
(SELECT post_title,'post' as type FROM posts WHERE post_title LIKE '%"')";
mysqli_query($connection,$query);
Thank you in anticipation.