简体   繁体   English

如何从一张表中选择两行?

[英]How to select two rows from one table?

I would like to use mysql_query to select two rows from one table with the usage of pid twice.我想使用mysql_query从一个表中选择两行,同时使用pid两次。

Like this:像这样:

<?php $result = mysql_query("SELECT * FROM posts WHERE pid='$user1' AND pid='$user2' order by id desc limit 50") ?>

Is this possible?这可能吗?

Try this..尝试这个..

SELECT * FROM posts WHERE pid='$user1' OR pid='$user2' order by id desc limit 50

Hope this helps.希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mysql join查询从两个表中选择行,一个表有多个与第一个表匹配的行 - mysql join query for select rows from two tables that one table is having multiple rows matching to the first table 如何从两个mysql表中选择不匹配的行 - How to select non-matching rows from two mysql table 如何将MySQL表中的两行连接到第三行 - How to join two rows from a mysql table into a third one 如何将表的行从一个数据库插入到另一个数据库(使用两个PDO) - How to insert rows of a table from one database to another (with two PDO) MySQL从同一表中选择两行 - MySQL select two rows from same table PHP / SQL:仅使用一个查询,如果两个表中都有数据,则从两个表中选择行;否则,仅从一个表中进行SELECT - PHP/SQL: Using only one query, SELECT rows from two tables if data is in both tables, or just SELECT from one table if not 如何从一个表中选择具有同一表中其他行的特定ID的行 - how to select rows from one table with specific id of other rows in the same table 如何从一个表而不是两个表中将此MySQL查询更改为SELECT? - How to change this MySQL query to SELECT from one table instead of two? 如何从两个表连接中 select 一个值? - How to select one value from a two table join? 从一种形式的表中连续两行 - Two consecutive rows into a table from one form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM