Title: Abase &#8211; sql with parameter
Last modified: August 24, 2016

---

# Abase – sql with parameter

 *  Resolved [rantonache](https://wordpress.org/support/users/rantonache/)
 * (@rantonache)
 * [10 years, 12 months ago](https://wordpress.org/support/topic/abase-sql-with-parameter/)
 * Hello,
 * I need to display a subset of records from a table using **sql** attribute, but
   I can’t find a way to merge a variable in the WHERE clause of SQL phrase.
    Any
   suggestion will be appreciated.
 * [https://wordpress.org/plugins/abase/](https://wordpress.org/plugins/abase/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [joseyaz](https://wordpress.org/support/users/joseyaz/)
 * (@joseyaz)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/abase-sql-with-parameter/#post-6175479)
 * This works for me. Search result with a SQL condition:
 *     ```
       [abase form="1,search" table="wp_routedb" columns="areaid,numtopo,name,gradenum,comment,in_10$Search dato" elements="areaid,numtopo,name,gradenum,comment,in_10"]
       [abase table="wp_routedb" columns="areaid,numtopo,name,gradenum,comment,in_10" where="AND <code>gradenum</code>='7b+'" echo="0" ack="blue"]
       ```
   
 * < code > = `
    form the forum replaces ` with < code >
 *  Thread Starter [rantonache](https://wordpress.org/support/users/rantonache/)
 * (@rantonache)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/abase-sql-with-parameter/#post-6175491)
 * Thank you very much for this solution.
    I have modified the file abase.php: _
   $myWhere=” WHERE userId = “.get\_current\_user\_id(); $sql\_in .= $myWhere;
 * I will try your version for the problem.
    Thanks a lot.
 * Radu.
 *  [ragordon](https://wordpress.org/support/users/ragordon/)
 * (@ragordon)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/abase-sql-with-parameter/#post-6175549)
 * Joseyaz
    I tried your suggestion and got an error. I am using the Abase shortcode
   in the sidebar. Maybe I don’t understand the use of ` ` I need to use a variable(
   $listing_id) as a search variable. in the code below hoaid= “$listing_id” –
 *  [abase table= “wp_awpcp_ads” columns = “ad_title, hoaid” notitle=”1″ where= “
   AND hoaid = ‘$lisitng_id’ ” echo=”0″]
 * Also in the sidebar I am retrieving the listing id (from a current directory 
   listing) with the following php, which works fine:
 *  <?php
    $id_or_slug = ”; if ( get_query_var( ‘listing’ ) || isset( $_GET[‘listing’]))
   $id_or_slug = get_query_var( ‘listing’ ) ? get_query_var( ‘listing’ ) : wpbdp_getv(
   $_GET, ‘listing’, 0 ); else $id_or_slug = get_query_var( ‘id’ ) ? get_query_var(‘
   id’ ) : wpbdp_getv( $_GET, ‘id’, 0 );
 * $listing_id = wpbdp_get_post_by_id_or_slug( $id_or_slug, ‘id’, ‘id’ );
    $field
   = wpbdp_get_form_field( 13); echo $field->display( $listing_id ); ?> <p> <?php
   echo $listing_id; ?> </p> <?php echo post_permalink( $listing_id ); ?>
 * I have been unable to come up with a way to grab this $listing_id (which is also
   the value in the other database in field hoaid) and use in in my Where clause.
 * Thanks
    ragordon

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Abase – sql with parameter’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/abase.svg)
 * [ABASE](https://wordpress.org/plugins/abase/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/abase/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/abase/)
 * [Active Topics](https://wordpress.org/support/plugin/abase/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/abase/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/abase/reviews/)

## Tags

 * [parameter](https://wordpress.org/support/topic-tag/parameter/)

 * 3 replies
 * 3 participants
 * Last reply from: [ragordon](https://wordpress.org/support/users/ragordon/)
 * Last activity: [10 years, 10 months ago](https://wordpress.org/support/topic/abase-sql-with-parameter/#post-6175549)
 * Status: resolved