Help needed to create query 10 Years, 6 Months ago
|
Karma: 0
|
I have two tables in the database
Table1:Subsribers
name, plan_id
Table2:Plan
plan_id, plan
I should like to create a table showing the records, as follows,
name plan
I can not join the tables. Would you please to help me with the query? I am new in SQL queries.
|
|
|
|
|
Re:Help needed to create query 10 Years, 6 Months ago
|
Karma: 760
|
Hello,
Use the following query:
Code: |
SELECT
S.name,
P.plan
FROM
Subscribers S INNER JOIN Plan P
ON S.plan_id = P.plan_id
|
Regards,
ARI Soft
|
|
|
|
|
Re:Help needed to create query 10 Years, 6 Months ago
|
Karma: 0
|
Thank you for the prompt answer. Here is my complete query, but I did something wrong, when I applied the sample.
SELECT S.membership_id, organization, first_name, last_name, country, date(created_date), P.title
FROM jos_osmembership_subscribers, S
WHERE published=1
INNER JOIN jos_osmembership_plans P ON S.plan_id=P.plan_id
What I did wrong?
|
|
|
|
|
Re:Help needed to create query 10 Years, 6 Months ago
|
Karma: 760
|
Try the following:
Code: |
SELECT
S.membership_id,
organization,
first_name,
last_name,
country,
date(created_date),
P.title
FROM
jos_osmembership_subscribers S INNER JOIN jos_osmembership_plans P
ON S.plan_id=P.plan_id
WHERE
published=1
|
Regards,
ARI Soft
|
|
|
|
|
Re:Help needed to create query 10 Years, 6 Months ago
|
Karma: 0
|
Thank you. It is working fine, but without the WHERE published=1
When it is in the query it returns with empty record, however there is records in the jos_osmembership_subscribers table, where the published value is 1. (No typo error.) The WHERE is working fine without the JOIN function.
|
|
|
|
|
Re:Help needed to create query 10 Years, 6 Months ago
|
Karma: 760
|
Try S.published = 1
Regards,
ARI Soft
|
|
|
|
|
|