hi to all
i am using union in select statement like this -
mysql> SELECT * FROM t1 UNION SELECT * FROM t2 UNION SELECT * FROM t3;
-
please tell me that is it possible that i can check value is come from which table (t1,t2 or t3)
let me know if i am not clear in my question
2 2219
i have done it by doing this -
SELECT
-
articles.id AS id,
-
articles.title_article AS title,
-
articles.contents AS contents,
-
1 as tableid
-
FROM articles
-
WHERE
-
(articles.status = '1'
-
and (articles.title_article like '%political news%' or articles.contents LIKE '%political news%')
-
)
-
UNION ALL
-
SELECT
-
press_release.id,
-
press_release.title,
-
press_release.description,
-
2 as tableid
-
FROM press_release
-
WHERE
-
(press_release.status = '1'
-
and (press_release.title like '%political news%' or press_release.author LIKE '%political news%' or press_release.description like '%political news%')
-
)
-
UNION
-
SELECT
-
latest_news.id,
-
latest_news.title,
-
latest_news.news,
-
3 as tableid
-
FROM latest_news
-
WHERE
-
(latest_news.status = '1'
-
and (latest_news.title like '%political news%' or latest_news.news LIKE '%political news%')
-
)
-
LIMIT 0, 50
Atli 5,058
Recognized Expert Expert
Hi.
I'm glad you found a solution!
Thank you for sharing it with us.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Stephen Patten |
last post by:
Hi All,
While in the process of building my table (40 or so Insert statments)
can I then query ("select * from @Table_variable") and use the results
up to theat point for another insert into @Table_varible? If you look
for stepID -15 I have commented that section out due to it not
retuning the correct values.
Thank you in advance
|
by: M Wells |
last post by:
Hi All,
Sorry if the subject line is too obscure -- I couldn't think of a way
of describing this request.
I have a table that contains approximately 1 million records.
I want to be able to be able to select the top x records out of this
table matching variable criteria.
|
by: SQLJunkie |
last post by:
Here is an issue that has me stumped for the past few days. I have a
table called MerchTran. Among various columns, the relevant columns for
this issue are:
FileDate datetime
, SourceTable varchar(25)
SQL statement:
SELECT DISTINCT
FileDate
|
by: serge |
last post by:
Using "SELECT * " is a bad practice even
when using a VIEW instead of a table?
I have some stored procedures that are
identical with the difference of one statement
in the WHERE clause. If I create a single View
and specify also in this View the WHERE clause
that is common in these stored procedures, I
will have the new stored procecures changed to
be like:
|
by: Bill |
last post by:
Hello out there;
This may be a challenge but I'm certain it's possible but I can't seem
to figure out how.
I have a table that has several date fields, e.g., Date1, Date2,
Date3, Date4 ... etc. I wish to find out either of two things for
each row.
1) What is the maximun date in any of the date fields in the row.
| |
by: kevinjbowman |
last post by:
I am by no means a SQl Jedi as will be apparent by my question, but I
can usually figure out a select statement on my own. I have one today
though that really has me stumped. I am working in MySQlL 5.
In My first select statement I get all my records from Table B
SELECT
`table_A`.`ITEM`,
`table_A`.`DECSCRIPTION`,
`table_A`.`UM`,
`table_A`.`PHASE`,
|
by: wugon.net |
last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad
query performance
Env:
db2 LUW V8 + FP14
Problem :
We have history data from 2005/01/01 ~ 2007/05/xx in single big
table,
we try separate this big table into twelve tables and create a view
|
by: imani_technology_spam |
last post by:
Right now, a client of mine has a T-SQL statement that does the
following:
1) Create a temp table.
2) Populate temp table with data from one table using an INSERT
statement.
3) Populate temp table with data from another table using an INSERT
statement.
4) SELECT from temp table.
|
by: Andrea Raimondi |
last post by:
Hello peers!
I'm working on this application and I'm in need for some thoughtful advice
:-p
I have an SQLDataSource with params, select, etc.
One of my params is the table name, which can be programmatically set, this
is necessary because I may have a
simple table name or a union, hence I got to pick the correct one!
Unfortunately, I can't bind this parameter to a control, session or
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |