logo
down
shadow

Selecting by two parameters from table


Selecting by two parameters from table

Content Index :

Selecting by two parameters from table
Tag : php , By : cynix
Date : November 28 2020, 11:01 PM

fixed the issue. Will look into that further You are expecting to a single user's name (title) to be matched against 2 (or more) patterns; which will not happen (unless the patterns are somewhat similar to each other).
What you need to do (in general) is to join different users (who are different authors of course) and filter them separately:
SELECT    doc_documents.id doc_id,
          doc_documents.projection_isbd doc_isbd
FROM      doc_documents
JOIN      doc_document_authors author1 ON author1.document_id = doc_documents.id
JOIN      doc_document_authors author2 ON author2.document_id = doc_documents.id
JOIN      usr_users user1 ON user1.id = author1.user_id
JOIN      usr_users user2 ON user2.id = author2.user_id
WHERE     doc_documents.status = 'CONFIRMED'
AND       db_type = 'PDB'
AND       NOT deleted
AND       (user1.title ilike $1 AND user2.title ilike $2)
ORDER BY  doc_documents.publish_date desc
SELECT    doc_documents.id doc_id,
          doc_documents.projection_isbd doc_isbd
FROM      doc_documents
JOIN      doc_document_authors ON doc_document_authors.document_id = doc_documents.id
JOIN      usr_users ON usr_users.id = doc_document_authors.user_id
WHERE     doc_documents.status = 'CONFIRMED'
AND       db_type = 'PDB'
AND       NOT deleted
GROUP BY  doc_documents.id -- this will only work when id is the primary key
                           -- otherwise use the primary key of doc_documents
                           -- or doc_documents.*
HAVING    bool_or(usr_users.title ilike $1)
AND       bool_or(usr_users.title ilike $2)
ORDER BY  doc_documents.publish_date desc

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to prevent selecting deleted IDs when selecting random row from sql table


Tag : php , By : Brian Cupps
Date : March 29 2020, 07:55 AM
it fixes the issue I want to select random rows from a product database by their unique id`s. I need 3-4 random products on every page... , You have a mistake in your script, do this:
$offset_result = mysql_query("SELECT FLOOR(RAND() * COUNT(*)) AS offset FROM `products`");
$offset_row = mysql_fetch_object($offset_result); 
$offset = $offset_row->offset;
$result = mysql_query("SELECT * FROM `products` LIMIT $offset, 1");
$n=mysql_num_rows($result);
$offset_result = mysql_query("SELECT COUNT(*) AS total FROM `products`");
$offset_row = mysql_fetch_object($offset_result); 

$total = (($offset_row->total) - 1);
$range_arr = range(0, $total);
shuffle($range_arr);
$off_1 = $range_arr[0];
$off_2 = $range_arr[1];
$off_3 = $range_arr[2];

$result = mysql_query(" (SELECT * FROM `products` LIMIT $off_1, 1)
                        UNION
                        (SELECT * FROM `products` LIMIT $off_2, 1)
                        UNION
                        (SELECT * FROM `products` LIMIT $off_3, 1)");
$n=mysql_num_rows($result);

Linq Query returning null parameters when selecting whole table


Tag : chash , By : Igor Carron
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , most probably the result of where condition is null in the linq query.
var info = context.Contacts.Where(x => x.Id == m.recipient.Id)
                                .Select(x => x.MobileNumber).FirstOrDefault()
var mobileNumber = string.Empty; //if it is not a string then initialize with proper value
var info = context.Contacts.FirstOrDefault(x => x.Id == m.recipient.Id);
if(info != null)
    mobileNumber = info.MobileNumber;
var msgs = context.Messages.ToList();
var msgs = context.Messages.Include(b => b.Recipients).ToList();

Implementatio of radio button in html table. Issue: All are selecting instead of selecting one


Tag : jquery , By : Noah
Date : March 29 2020, 07:55 AM
Hope this helps you have to put a common name on the radio buttons you want to group.
Like :
<input type="radio" id="radio4" name="radio" />
<input type="radio" id="radio5" name="radio" />
<input type="radio" id="radio6" name="radio" />
....
....

Selecting child table's row upon selecting parent table's row using Jquery


Tag : javascript , By : Bas
Date : March 29 2020, 07:55 AM
this one helps. Current element is checkbox so it can't have TR as siblings use .closest() to traverse up to parent TR element then perform the desired DOM traversal methods i.e. .siblings(), .find() to target the desired elements
$(this).closest('tr').find(...)
$(this).closest('tr').siblings('tr').find(...)
$(function() {
  $("input[type='checkbox']").change(function() {
    $(this).closest('tr')
      .find("input[type='checkbox']")
      .prop('checked', this.checked);
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<div id="divSAcheckBox" style="display: inline; left: 37px; position: relative;"><input id="SAcheckBox" name="SAcheckBox" type="checkbox" /> Select All</div>
<table id="parentTable" class="display dataTable no-footer" style="position: relative; top: 0px; width: 911px; table-layout: fixed;" role="grid">
  <thead>
    <tr style="height: 0px;" role="row">
      <th class="sorting_disabled" style="width: 0px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" colspan="1" rowspan="1">&nbsp;</th>
      <th id="chkbox" class="sorting_disabled" style="width: 51px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" colspan="1" rowspan="1">Select
        <div class="dataTables_sizing" style="height: 0; overflow: hidden;">Select</div>
      </th>
      <th id="media" class="sorting" style="border-left: 1px dashed #111111; text-align: left; width: 51px; padding-top: 0px; padding-bottom: 0px; border-top-width: 0px; border-bottom-width: 0px; height: 0px;" colspan="1" rowspan="1">Media
        <div class="dataTables_sizing" style="height: 0; overflow: hidden;">Media</div>
      </th>
    </tr>
  </thead>
  <tbody>
    <tr class="odd shown" role="row" align="left">
      <td class="sorting_1"><input style="cursor: pointer;" type="checkbox" align="center" /></td>
      <td class="details-control" style="width: 51px;">&nbsp;</td>
      <td style="width: 51px;">Phone</td>
      <td style="width: 90px;" colspan="9">
        <table id="issuetable_12_13_2018_13_23_34" class="stripe nowrap" style="position: relative; margin: 5px 0 0 30px; cellspacing=0; border-collapse: collapse; align-text: left; top: 0px; width: 95%;">
          <thead>
            <tr>
              <th>&nbsp;</th>
            </tr>
            <tr>
              <th>&nbsp;</th>
              <th>&nbsp;</th>
            </tr>
            <tr>
              <th>&nbsp;</th>
              <th>&nbsp;</th>
            </tr>
            <tr>
              <th>&nbsp;</th>
              <th>&nbsp;</th>
            </tr>
            <tr>
              <th>&nbsp;</th>
            </tr>
            <tr>
              <th style="border: 1px solid #333333; text-align: left; width: 333px;" nowrap="nowrap" bgcolor="#FAF6F2">Select</th>
              <th style="border: 1px solid #333333; text-align: left; width: 407px;" nowrap="nowrap" bgcolor="#FAF6F2">Priority</th>
            </tr>
          </thead>
          <tbody>
            <tr align="left">
              <td style="width: 333px;" nowrap="nowrap"><input style="cursor: pointer;" type="checkbox" align="center" />&nbsp;</td>
              <td style="width: 407px;" nowrap="nowrap">999</td>
            </tr>
          </tbody>
        </table>
      </td>
    </tr>
  </tbody>
</table>

Do selecting directly from table and selecting from view have the same performance impact


Tag : sql , By : James Cary
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • How to get values greater than or equal to in Mysql database sql when its a value like 1:00 PM?
  • PHP datediff overday issue
  • Masking an auto incrementing primary key
  • How to grab a String BEFORE a certain word
  • ZF2 Routing Multiple Controllers based on route constraints
  • How to deregister/dequeue jquery.sticky.js in Elementor (Pro)?
  • How to fix errors counting words in text plain with PHP?
  • How to get View data in Laravel in custom helper or directive
  • Creating a new data entry into a database with eloquent and trying to access the variable in the url
  • How to test authentication using Laravel Dusk?
  • PHP parse_str not getting all $_GET variables
  • Variable issues in php class
  • Get orders between dates in Codeigniter
  • Eloquent Special Chars Issue
  • Keeping leading zeros column Mysql
  • Current level navigation in Wordpress
  • Add a custom text to WooCommerce cart items if the product has a specific shipping class
  • Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate
  • How do I add a new key value pair to an object in PHP?
  • Http post request to php with dart
  • How to add a route in with blade into parameters of a component
  • How can i get the source of a 777 - CHMOD php file?
  • Convert 2010-04-16 16:30:00 to "Tomorrow Afternoon"
  • How can I hide a $_GET variable to be more secured in PHP?
  • Login to Gmail Inbox using Curl?
  • Upload Excel or CSV file to MySQL with PHP
  • Outlook Marking Email as Junk Email
  • Upload an image using class.upload.php via AJAX, display image in form using jQuery
  • mysql_connect() causes page to not display (WAMP)
  • How to limit a users uploaded image size using PHP
  • What's the difference whether or not to run PHP in safe mode?
  • Logging in to a website cURL
  • Using php to create a password system with chinese characters
  • PHP is not called properly in IE using set interval function in Javascript
  • How to read pdf, ppt, xl, doc files content into a string in php/python
  • php script for currency conversion
  • In PHP... best way to turn string representation of a folder structure into nested array
  • PayPal for Indian Rupees (INR) any solution
  • PHP Deployment to Live Server
  • Ideal Multi-Developer Lamp Stack?
  • How can I save an image from a file input field using PHP & MySQL?
  • Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in
  • Connecting to external MySQL DB from a web server not running MySQL
  • Is it possible to add custom fields to a Drupal taxonomy term?
  • PHP 6.0 - Roadmap?
  • jQuery wait for ajax call to be over before continuing
  • checkUnique function?
  • How to define an n-m relation in doctrine?
  • Sort the unsorted text file and rewrite to same text file in sorted order
  • Version control a content management system?
  • How can i run Single PHP File using apache-tomcat-6.0.18?
  • Array of objects is empty when I come to retrieve one from the array
  • PHP Library: Calculate a bounding box for a given lat/lng location
  • Good Wordpress Theme/plugin for showing off code examples and scripts
  • Replace all spaces and special symbols with dash in URL using PHP language
  • globally get any field value in user table of logged in user
  • Can you get a job if you know XHTML, CSS and Basic PHP?
  • HTML Upload Form will only upload files found in the directory of the PHP file
  • Determine if a PHP array uses keys or indices
  • Are frameworks really necessary for beginners/intermediates?
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com