mysql如果select是我的id,则不返回任何行

时间:2018-06-01 22:45:01

标签: mysql

我有一个出价表,id,sellerId,buyerId,notifId amount .... 如果我的id(sellerId)存在且notifId不存在我不想返回任何行 所以我的sellerId是50001,我已经对notifId 1260出价,没有返回结果,那很好我可以做到这一点,但它将返回卖方1442的行,同样的报告。 如果我的id存在于具有相同notifid的任何行,我不想返回任何内容 希望像泥一样清楚。

 Application.Run("Test",
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
            Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

而不是EXISTS             (             SELECT null             FROM notification_hide nh             WHERE nh.notifId = n.notifId和nh.sellerId = sellerId             ))

SELECT n.notifId, n.senderId, n.sellerTypeId, n.subject, ur.model, n.message, n.firstname, n.lastname, n.email, n.days, n.created_date, DATE_ADD( n.created_date, INTERVAL n.days
DAY ) AS  'dateExpires', n.requestId, ur.subCategoryId, ur.item, ur.addressStreet, ur.addressCity, ur.addressState, ur.addressZip, ur.addressAlt, ur.tvscreen, ur.tvtype, ur.tvmount, ur.dvdregion, ur.dvdusb, ur.soundtype, ur.soundwireless, ur.createdDate,
            ur.gametype, ur.fridgesize, ur.fridgeheight, ur.fridgewidth, ur.fridgedepth, ur.fridgetype, ur.fridgeexterior,
            ur.washsize, ur.washheight, ur.washwidth, ur.washdepth, ur.washtype, ur.washexterior, DATEDIFF( DATE_ADD( n.created_date, INTERVAL n.days
DAY ) , NOW( )+ INTERVAL 0 HOUR ) AS daysLeft, TIMESTAMPDIFF( HOUR , NOW( )+ INTERVAL 0 HOUR , DATE_ADD( n.created_date, INTERVAL n.days
DAY ) ) AS hoursLeft,
TIMESTAMPDIFF( MINUTE , NOW( )+ INTERVAL 0 HOUR , DATE_ADD( n.created_date, INTERVAL n.days
DAY ) ) AS minutesLeft, u.phoneNumber, ur.hasBid, ur.numItems, ur.electricity, ur.gas, ur.solar, ur.concession, ur.phone,
b.amount, COALESCE(b.bidAccepted, 0) AS bidAccepted, b.amount, b.powerCents, b.powerFee, b.powerDiscount, b.gasCents, b.gasFee, b.gasDiscount, b.additionalInfo, COALESCE(b.isLowestBid, 0) as isLowestBid, uri.imageName, ura.fileName, ih.address as homeinsaddress, ih.built, ih.propertyValue, ih.dwelling, ih.insurance, ih.moving, ih.owner, ih.previousClaimSelected as homeClaimSelected, ih.previousClaim as homeClaim, ih.requiredby as homeinsrequiredby,
ic.registration, ic.carmake, ic.carmodel, ic.caryear, ic.carfinance, ic.damage, ic.insured, ic.insurerName, ic.modifications, ic.modsValue, ic.nonstandard, ic.theftdevice, ic.gender, ic.garaged, ic.address as caraddress, ic.insType, ic.useType, ic.useFor, ic.age, ic.dob, ic.licenceYear, ic.estValue, ic.previousClaimSelected, ic.previousClaim, ic.licenceSuspended, ic.additionalDrivers, ic.requiredby as carinsrequiredby,
ip.petname, ip.petbreed, ip.petdesexed, ip.petgender, ip.pettype, ip.petborn, ip.petrequiredby, ip.petEstValue, ip.previousClaimSelected as petClaimSelected, ip.previousClaim as petClaim,
 h.address as healthaddress, h.covered, h.coverfor, h.income, h.rebate, h.yearbirth, h.requiredby as healthrequiredby, h.preExisting, h.healthPrimary, ur.categoryId, ur.subCategoryId, f.id as flightId, f.class, f.departure, f.departureDate, f.destination, f.oneWay, f.passengers, f.adults, f.children, f.cheapestFare, f.stopOvers, f.departureTime, f.layover, f.numNights, f.rating, f.details, f.returnDate,
hc.id as hireCarId, hc.driverAge, hc.dropoffDateTime, hc.dropoffLocation, hc.pickup, hc.pickupDateTime, hc.purpose, hc.vehicleType, c.id as cameraId, c.cameraType, c.cameraBrand, c.compactType, c.touchScreen, c.tiltable, c.wifi, c.waterProof, c.memoryCard, c.externalFlash, c.cameraCase, c.extraBattery, c.details as cameraDetails, COALESCE(r.id, 0) as ratingId, tt.taxiType
FROM notifications n
LEFT OUTER JOIN users u ON u.id = n.senderId
LEFT OUTER JOIN user_request ur ON ur.id = n.requestId

LEFT OUTER JOIN bids b ON b.notifId = n.notifId
LEFT OUTER JOIN user_request_images uri ON b.sellerId = uri.userId
LEFT OUTER JOIN user_request_attachments ura ON b.sellerId = ura.userId

LEFT OUTER JOIN insurance_home ih ON ur.id = ih.requestId
LEFT OUTER JOIN insurance_car ic ON ur.id = ic.requestId
LEFT OUTER JOIN insurance_pets ip ON ur.id = ip.requestId
LEFT OUTER JOIN insurance_health h ON ur.id = h.requestId
LEFT OUTER JOIN recreation_flights f ON ur.id = f.requestId
LEFT OUTER JOIN recreation_hirecar hc ON ur.id = hc.requestId
LEFT OUTER JOIN ratings r ON ur.id = r.requestId
LEFT OUTER JOIN taxi_types tt ON ur.taxiTypeId = tt.taxiTypeId
LEFT OUTER JOIN camera c ON ur.id = c.requestId
WHERE  (n.sellerTypeId = sellerTypeId and COALESCE(b.bidAccepted, 0) = bidsWon
    AND (FIND_IN_SET(ur.subCategoryId, _subCategories) )

Bids table

0 个答案:

没有答案