Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9186611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:34:17+00:00 2026-06-17T19:34:17+00:00

My current queries. Can I combine them in to fewer to get the same

  • 0

My current queries. Can I combine them in to fewer to get the same result? I am trying to get specific information about the trail into an array named $trail.

$result = mysql_query("SELECT meta_value FROM wp_postmeta WHERE `post_id` = $id AND `meta_key` = 'location_city' ");
$result = mysql_fetch_array($result);
$trail[city] = $result[0];

$result = mysql_query("SELECT meta_value FROM wp_postmeta WHERE `post_id` = $id AND `meta_key` = 'length' ");
$result = mysql_fetch_array($result);       
$trail[length] = $result[0];

$result = mysql_query("SELECT meta_value FROM wp_postmeta WHERE `post_id` = $id AND `meta_key` = 'location_state' ");
$result = mysql_fetch_array($result);
$trail[state] = $result[0];

$result = mysql_query("SELECT meta_value FROM wp_postmeta WHERE `post_id` = $id AND `meta_key` = 'difficulty' ");
$result = mysql_fetch_array($result);
$trail[difficulty] = $result[0];

$result = mysql_query("SELECT guid FROM wp_posts WHERE `post_parent` = $id AND `post_type` = 'attachment' ");
$result = mysql_fetch_array($result);
$trail[image] = $result[0];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:34:19+00:00Added an answer on June 17, 2026 at 7:34 pm

    If you want the data in columns, then you could JOIN the queries:

    SELECT lc.meta_value Location_City,
        l.meta_value Location,
        ls.meta_value LocationState,
        d.meta_value Difficulty,
        p.guid
    FROM wp_postmeta lc
    LEFT JOIN wp_postmeta l
        on lc.`post_id` = l.`post_id`
        and l.`meta_key` = 'length'
    LEFT JOIN wp_postmeta ls
        on lc.`post_id` = ls.`post_id`
        and ls.`meta_key` = 'location_state'
    LEFT JOIN wp_postmeta d
        on lc.`post_id` = d.`post_id`
        and d.`meta_key` = 'difficulty'
    LEFT JOIN wp_posts p
        on lc.`post_id` = p.`post_parent`
        and p.`post_type` = 'attachment'
    WHERE lc.`post_id` = $id 
        AND lc.`meta_key` = 'location_city' 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to see if I can combine 3 LINQ queries into one.
Current Process: I have a tar.gz file. (Actually, I have about 2000 of them,
I want to get the weather information for a specific location. Right now, I
I've always been confused on how to combine multiple MySQL queries into one. I've
How can I access the current user information via LDAP and VB.Net 2.0*? I
I want to combine the following queries into a single query: SELECT val FROM
I'm trying to build a SOA where clients can perform long running queries on
Hallo. How can I get the date of last friday of current month with
These queries: https://developer.valvesoftware.com/wiki/Server_queries Can return many things about a [TF2] server, such as player
These two queries work: SELECT u.id, u.email, COUNT(*) as Current FROM users u, rounds

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.