We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Help writing an SQL Query to find the channel of an entry

Development and Programming

igrandfunk's avatar
igrandfunk
13 posts
15 years ago
igrandfunk's avatar igrandfunk

Hello there EE forum members,

SQL is a little over my head and I have conducted Google and EE forum searches, but I am unable to find a solution (SQL, addon, built in functionality, etc.). I am wanting to find the channel of a particular entry in my database. I would assume it would be something like this…

SELECT channel_name FROM `exp_channels` WHERE entry_id = 63;

It is kind of a reverse approach. We have an entry ID being displayed on a template but only an excerpt is showing, so we want to have a read more link to the entire entry, which is why we want the channel of the particular post included in the EE anchor link.

Thanks!

       
Jack Scott's avatar
Jack Scott
18 posts
15 years ago
Jack Scott's avatar Jack Scott

Hello igrandfunk,

You can read the channel name with something like:

SELECT c.channel_name
FROM exp_channel_titles AS t
JOIN exp_channels AS c ON t.channel_id = c.channel_id
WHERE t.entry_id = 'my_id'

where ‘my_id’ is your entry id number.

       
Miguel Garcia's avatar
Miguel Garcia
2 posts
15 years ago
Miguel Garcia's avatar Miguel Garcia

Jack,

Thank you very much. This solution worked for me and I was able to learn how you called in the channel name/ID by joining the tables. Thanks again!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.