עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בכתיבת שאילתות mysql

Featured Replies

פורסם

שלום!

לא מזמן התחלתי ללמוד sql(בתוכנת mysql).נתקלתי בבעיה בכתיבת השאילתה הבאה:

הצג את כמות החלב המירבית שהניבה פרה ברפת ואת קודי הפרות שהניבו כמות זו

כאשר בסיס הנתונים הוא:

cow(name,id,age)

milk_product(cow_id,amount)

כתבתי את השאילתה הבאה:

select id,max(amount)

from test.cow,test.cow_prduct;

where cow_id=id

group by id

אבל אני מקבלת id אחר ולא של הפרה שהניבה את הכמות המקס'

תודה מראש hi.gif

פורסם

תערכי את ההודעה ושימי את הקוד בתוך טג קוד (כפתור # למעלה), כדי שיהיה קריא יותר.

לשאלתך: שימי לב שבכלל לא עשית סינון (where) לפי המקסימום, אלא רק שלפת אותו. מה שעשית למעשה הוא לשלוף מכל רשומה את ה-id שלה ואת (max(amount בכלל, כלומר כל רשימה בשליפה תכיל בדיוק אותו דבר בשדה השני.

פורסם
  • מחבר

תודה.

תוכל בבקשה לנסח את השאילתה החדשה,עם התיקונים?

 
כאשר בסיס הנתונים הוא:
cow(name,id,age)
milk_product(cow_id,amount)



select id,max(amount)
from test.cow,test.cow_prduct;
where cow_id=id
group by id

פורסם

תן לי להבין. אתה רוצה לשלוף לכל פרה את כמות החלב המקסימלית שהיא ייצרה, מבין כל הרשומות שרלוונטיות אליה ב-milk_product? אם כן אז זה דווקא אמור לעבוד...

(חוץ מזה שלא ברור לי למה יש ; אחרי ה-where, הוא לא נחוץ).

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.