473,383 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

PHP Query for Multiple Database Tables

I've been trying to figure this out for hours, but it seems so simple--that's why I'm so frustrated. I have three tables (newsarticles, sportsarticles, opinionarticles) with identical structures in a database and a search query on my website that, at this point, can search through only the "newsarticles" table. The code for the working search of the "newsarticles" table is shows below:

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM newsarticles WHERE newsarticles.text LIKE %s  OR newsarticles.title LIKE %s OR newsarticles.author LIKE %s
I want to be able to use the search query to return a single recordset of results that includes results from all three tables. Some possible solutions I have found are the "JOIN" and "UNION" SQL commands. I am not sure if either will work, or if either is correct to use in this case. Does anyone have any ideas?
Dec 1 '07 #1
1 1675
MarkoKlacar
296 Expert 100+
Hi,

I'm guessing that you want to serach the tables that have a certain keyword stored in them, am I right?

In that case you need to look at the "JOIN" or "UNOIN" a bit more.

I think you'll merge your tables by selecting something from every table if they have a matching keyword or criteria.

Hope I wasn't to far off.

Cheers
Dec 3 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Rigga | last post by:
Hi, I am new to mysql and need help on how to join tables. I have a database which contains 4 tables, the main table contains information by date order and the other 3 contain data also in date...
4
by: sci | last post by:
Could someone help me by answering the questions below? What's a cursor? What's difference between Query and View? Is a RecordSet just part of a table? Can it be part of a query of view? If...
11
by: deko | last post by:
If I release a new version of my mbd (in mde format) and users want to upgrade - how do they migrate their data? For example, if the original was released as data1.mde and then I release...
10
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have...
1
by: fong.yang | last post by:
I've got a database with about 300,000 records. There are several different tables that are set up the same way with identical fields. I have the same queries individually set up for each table. ...
2
by: Allen Anderson | last post by:
Hi, I'm trying to design contact (names and addresses) tables in an Access database. Some of the contacts represent vendors, some are board members of the organization, some are donors, some...
7
by: Daz | last post by:
Hi. I am trying to select data from two separate MySQL tables, where I cannot use join, but when I put the two select queries into a single query, I get an error telling me to check my syntax. Both...
1
by: crazdandconfusd | last post by:
I have a database with two tables I use for shipping information. One is for if I'm only shipping one item and the other is for a back page of a report for when I ship multiple items. If I'm...
2
by: starke1120 | last post by:
I have a query that has a prompt for date as Between And This database is hosted on a share drive. About half of my user's are ok with the report that has this query the other half when the...
6
by: gerbski | last post by:
Hi all, I am relatively new to ADO, but up to now I got things working the way I wanted. But now I've run into somethng really annoying. I am working in MS Access. I am using an Access...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.