DeltaSector
DeltaSector

Reputation: 37

Sub-Select statement outside main query statement

the answer might be staring at me in the face but i cant for the life of me figure it out so i have this

"SELECT count(*), template_name, sent, date_inserted, ln_project_id, project_name 
    FROM mailer_events
    INNER JOIN ln_mailer_events 
    USING ( mailer_event_id ) 
    LEFT OUTER JOIN ln_logs 
    USING ( ln_log_id ) 
    INNER JOIN ln_actions 
    USING ( ln_action_id ) 
    inner join ln_projects 
    using (ln_project_id) 
    inner join mailer_templates 
    using ( mailer_template_id)

    WHERE {$idorname} = '{$p_id}' 
    and sent > '{$sent_date_string}' and mailer_drip_id =0 
    group by mailer_template_id"; 

Thats my main query and it responds if my search is numeric. problem i want a different select statement if its text or string using the answer from the main query like so:

"SELECT ln_project_id from ln_projects where project_name = `{$p_id}`";

but that doesnt work.

Upvotes: 1

Views: 59

Answers (1)

use LIKE Operator:

$query = "SELECT ln_project_id from ln_projects where project_name LIKE '%". 
$some_text_variable."%' "; 

Upvotes: 1

Related Questions