Solved

Help required writing a complex query

Posted on 2013-05-15
3
241 Views
Last Modified: 2013-05-15
I have 2 tables:

1) content_permissions

CREATE TABLE content_permissions (`id` integer PRIMARY KEY,
  `tbl_content_common_id` int(10) NOT NULL,
  `userneed_permission_id` int(10) NOT NULL,
  `created` timestamp NOT NULL,
  `modified` timestamp NOT NULL
 )
                                  

Open in new window



2) userneed_permissions

CREATE TABLE `userneed_permissions` (
  `id`  integer PRIMARY KEY,
  `name` varchar(100) NOT NULL,
  `permission_main_title_id` int(10) NOT NULL,
  `description` text NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL
)
                                  

Open in new window


For a given tbl_content_common_id of the first table(content_permissions) , I need to get all the values corresponding to the name column of second table(userneed_permissions ) with the where condition userneed_permission_id(first table) = id(second table) for a given tbl_content_common_id(first table)
0
Comment
Question by:Sreejith22
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 250 total points
ID: 39169228
You mean something like this?

select UP.name from
content_permissions CP
inner join
userneed_permissions UP
on CP.userneed_permission_id = UP.id
where CP.tbl_content_common_id = ?

Open in new window

0
 

Author Comment

by:Sreejith22
ID: 39169260
precisely.

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39169280
:)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now